GALMj version ≥ 2.4.0
GAMLj module can be installed and used in R as a standard R packages. Please check the R help for details. Here we provide some appliactions of the package in R.
At the moment, GAMLj is not in CRAN yet, so you need to install it via devtools
devtools::install_github("gamlj/gamlj")
General Linear Model. Estimates models using ‘lm()’ function and provides options to facilitate estimation of
interactions, simple slopes, simple effects, posthoc tests, contrast analysis, effect size indexes and visualization of the results.
gamljGlm( data, formula, dep = NULL, factors = NULL, covs = NULL, modelTerms = NULL, fixedIntercept = TRUE, showParamsCI = TRUE, paramCIWidth = 95, contrasts = NULL, showRealNames = TRUE, showContrastCode = FALSE, plotHAxis = NULL, plotSepLines = NULL, plotSepPlots = NULL, plotRaw = FALSE, plotDvScale = FALSE, plotError = "none", ciWidth = 95, postHoc = NULL, eDesc = FALSE, eCovs = FALSE, simpleVariable = NULL, simpleModerator = NULL, simple3way = NULL, simpleScale = "mean_sd", cvalue = 1, percvalue = 25, simpleScaleLabels = "labels", postHocCorr = list("bonf"), scaling = NULL, effectSize = list("beta", "partEta"), homoTest = FALSE, qq = FALSE, normTest = FALSE, normPlot = FALSE, residPlot = FALSE, interceptInfo = FALSE, effectSizeInfo = FALSE, dep_scale = "none" )
data

the data as a data frame 
formula

(optional) an object of class 
dep

a string naming the dependent variable; the variable must be numeric. Not needed if 
factors

a vector of strings naming the fixed factors. Not needed if 
covs

a vector of strings naming the covariates (continuous variables). Not needed if 
modelTerms

a list of character vectors describing fixed effects terms. Not needed if 
fixedIntercept


showParamsCI


paramCIWidth

a number between 50 and 99.9 (default: 95) specifying the confidence interval width for the parameter estimates 
contrasts

a named vector of the form 
showRealNames


showContrastCode


plotHAxis

a string naming the variable placed on the horizontal axis of the plot 
plotSepLines

a string naming the variable represented as separate lines in the plot 
plotSepPlots

a string naming the variable defining the levels for multiple plots 
plotRaw


plotDvScale


plotError


ciWidth

a number between 50 and 99.9 (default: 95) specifying the confidence interval width for the plots. 
postHoc

a rhs formula with the terms specifying the table to apply the comparisons (of the form 
eDesc


eCovs


simpleVariable

The variable for which the simple effects (slopes) are computed 
simpleModerator

the variable that provides the levels at which the simple effects are computed 
simple3way

a moderator of the twoway interaction which is probed 
simpleScale


cvalue

how many st.deviations around the means used to condition simple effects and plots. Used if 
percvalue

offsett (number of percentiles) around the median used to condition simple effects and plots. Used if 
simpleScaleLabels

how the levels of a continuous moderator should appear in tables and plots: 
postHocCorr

one or more of 
scaling

a named vector of the form 
effectSize

a list of effect sizes to print out. They can be: 
homoTest


qq


normTest


normPlot


residPlot


interceptInfo


effectSizeInfo


dep_scale

Rescale the dependent variable. It can be 
data('ToothGrowth') gamlj::gamljGlm(formula = len ~ supp, data = ToothGrowth)
Generalized Mixed Linear Model. Estimates models using ‘lme4::glmer()’ function and provides options to facilitate estimation of
interactions, simple slopes, simple effects, posthoc tests, contrast analysis, effect size indexes and visualization of the results.
gamljGlmMixed( data, formula = NULL, dep = NULL, factors = NULL, covs = NULL, modelTerms = NULL, fixedIntercept = TRUE, showParamsCI = FALSE, showExpbCI = TRUE, paramCIWidth = 95, contrasts = NULL, showRealNames = TRUE, showContrastCode = FALSE, plotHAxis = NULL, plotSepLines = NULL, plotSepPlots = NULL, plotRaw = FALSE, plotDvScale = FALSE, plotError = "none", ciWidth = 95, postHoc = NULL, eDesc = FALSE, eCovs = FALSE, simpleVariable = NULL, simpleModerator = NULL, simple3way = NULL, simpleScale = "mean_sd", cvalue = 1, percvalue = 25, simpleScaleLabels = "labels", postHocCorr = list("bonf"), scaling = NULL, cluster = NULL, randomTerms = list(list()), correlatedEffects = "corr", plotRandomEffects = FALSE, plotLinearPred = FALSE, nAGQ = 1, effectSize = list("expb"), modelSelection = "logistic", custom_family = "gaussian", custom_link = "identity", cimethod = "wald" )
data

the data as a data frame 
formula

(optional) the formula to use. The syntax is the same used in [lme4::lmer()]. See the examples 
dep

a string naming the dependent variable from 
factors

a vector of strings naming the fixed factors from 
covs

a vector of strings naming the covariates from 
modelTerms

a list of character vectors describing fixed effects terms 
fixedIntercept


showParamsCI


showExpbCI


paramCIWidth

a number between 50 and 99.9 (default: 95) specifying the confidence interval width for the parameter estimates 
contrasts

a named vector of the form 
showRealNames


showContrastCode


plotHAxis

a string naming the variable placed on the horizontal axis of the plot 
plotSepLines

a string naming the variable represented as separate lines on the plot 
plotSepPlots

the variable for whose levels multiple plots are computed 
plotRaw


plotDvScale


plotError


ciWidth

a number between 50 and 99.9 (default: 95) specifying the confidence interval width 
postHoc

a list of terms to perform posthoc tests on 
eDesc


eCovs


simpleVariable

The variable for which the simple effects (slopes) are computed 
simpleModerator

the variable that provides the levels at which the simple effects computed 
simple3way

a moderator of the twoway interaction which is probed 
simpleScale


cvalue

offset value for conditioning 
percvalue

offset value for conditioning 
simpleScaleLabels

decide the labeling of simple effects in tables and plots. 
postHocCorr

one or more of 
scaling

a named vector of the form 
cluster

a vector of strings naming the clustering variables from 
randomTerms

a list of lists specifying the models random effects. 
correlatedEffects


plotRandomEffects


plotLinearPred


nAGQ

for the adaptive GaussHermite loglikelihood approximation, nAGQ argument controls the number of nodes in the quadrature formula. A positive integer 
effectSize

. 
modelSelection

Select the generalized linear model: 
custom_family

Distribution family for the custom model, accepts gaussian, binomial, gamma and inverse_gaussian . 
custom_link

Distribution family for the custom model, accepts identity, log and inverse, onemu2 (for 1/mu^2). 
cimethod

. 
data(subjects_by_stimuli) gamlj::gamljMixed( formula = y ~ 1 + cond+( 1subj ), data = subjects_by_stimuli) gamlj::gamljMixed( data = subjects_by_stimuli, dep = "y", factors = "cond", modelTerms = "cond", cluster = "subj", randomTerms=list(list(c("cond","subj"))))
Generalized Linear Models. Estimates models using ‘glm()’ function and similar functions. It provides options to facilitate estimation of
interactions, simple slopes, simple effects, posthoc tests, contrast analysis, effect size indexes and visualization of the results.
gamljGzlm( data, dep, factors = NULL, covs = NULL, modelTerms = NULL, fixedIntercept = TRUE, showParamsCI = FALSE, showExpbCI = TRUE, paramCIWidth = 95, contrasts = NULL, showRealNames = TRUE, showContrastCode = FALSE, plotHAxis = NULL, plotSepLines = NULL, plotSepPlots = NULL, plotRaw = FALSE, plotDvScale = FALSE, plotError = "none", ciWidth = 95, postHoc = NULL, eDesc = FALSE, eCovs = FALSE, simpleVariable = NULL, simpleModerator = NULL, simple3way = NULL, simpleScale = "mean_sd", cvalue = 1, percvalue = 25, simpleScaleLabels = "labels", postHocCorr = list("bonf"), scaling = NULL, effectSize = list("expb"), modelSelection = "linear", custom_family = "gaussian", custom_link = "identity", formula )
data

the data as a data frame 
dep

a string naming the dependent variable from 
factors

a vector of strings naming the fixed factors from 
covs

a vector of strings naming the covariates from 
modelTerms

a list of character vectors describing fixed effects terms 
fixedIntercept


showParamsCI


showExpbCI


paramCIWidth

a number between 50 and 99.9 (default: 95) specifying the confidence interval width for the parameter estimates 
contrasts

a named vector of the form 
showRealNames


showContrastCode


plotHAxis

a string naming the variable placed on the horizontal axis of the plot 
plotSepLines

a string naming the variable represented as separate lines on the plot 
plotSepPlots

a string naming the variable to separate over to form multiple plots 
plotRaw


plotDvScale

. 
plotError


ciWidth

a number between 50 and 99.9 (default: 95) specifying the confidence interval width 
postHoc

a list of terms to perform posthoc tests on 
eDesc


eCovs


simpleVariable

The variable for which the simple effects (slopes) are computed 
simpleModerator

the variable that provides the levels at which the simple effects computed 
simple3way

a moderator of the twoway interaction which is probed 
simpleScale


cvalue

offset value for conditioning 
percvalue

offset value for conditioning 
simpleScaleLabels

style for presenting condition values of a moderator. It can be 
postHocCorr

one or more of 
scaling

a named vector of the form 
effectSize

. 
modelSelection

Select the generalized linear model: 
custom_family

Distribution family for the custom model, accepts gaussian, binomial, gamma and inverse_gaussian . 
custom_link

Distribution family for the custom model, accepts identity, log and inverse, onemu2 (for 1/mu^2). 
formula

(optional) the formula to use, see the examples 
data<emmeans::neuralgia gamlj::gamljGzlm( formula = Pain ~ Duration, data = data, modelSelection = "logistic")
Mixed Linear Model. Estimates models using ‘me4::lmer()’ function and provides options to facilitate estimation of
interactions, simple slopes, simple effects, posthoc tests, contrast analysis, effect size indexes and visualization of the results.
gamljMixed( data, dep = NULL, factors = NULL, covs = NULL, modelTerms = NULL, fixedIntercept = TRUE, showParamsCI = TRUE, paramCIWidth = 95, ciRE = FALSE, contrasts = NULL, showRealNames = TRUE, showContrastCode = FALSE, plotHAxis = NULL, plotSepLines = NULL, plotSepPlots = NULL, plotRaw = FALSE, plotDvScale = FALSE, plotError = "none", ciWidth = 95, postHoc = NULL, eDesc = FALSE, eCovs = FALSE, simpleVariable = NULL, simpleModerator = NULL, simple3way = NULL, simpleScale = "mean_sd", cvalue = 1, percvalue = 25, simpleScaleLabels = "labels", postHocCorr = list("bonf"), scaling = NULL, dep_scale = "none", cluster = NULL, randomTerms = list(list()), correlatedEffects = "corr", reml = TRUE, lrtRandomEffects = FALSE, plotRandomEffects = FALSE, cimethod = "wald", dfmethod = "Satterthwaite", qq = FALSE, normTest = FALSE, normPlot = FALSE, residPlot = FALSE, clusterBoxplot = FALSE, randHist = FALSE, formula )
data

the data as a data frame 
dep

a string naming the dependent variable from 
factors

a vector of strings naming the fixed factors from 
covs

a vector of strings naming the covariates from 
modelTerms

a list of character vectors describing fixed effects terms 
fixedIntercept


showParamsCI


paramCIWidth

a number between 50 and 99.9 (default: 95) specifying the confidence interval width for the parameter estimates 
ciRE


contrasts

a named vector of the form 
showRealNames


showContrastCode


plotHAxis

a string naming the variable placed on the horizontal axis of the plot 
plotSepLines

a string naming the variable represented as separate lines on the plot 
plotSepPlots

the variable for whose levels multiple plots are computed 
plotRaw


plotDvScale


plotError


ciWidth

a number between 50 and 99.9 (default: 95) specifying the confidence interval width 
postHoc

a list of terms to perform posthoc tests on 
eDesc


eCovs


simpleVariable

The variable for which the simple effects (slopes) are computed 
simpleModerator

the variable that provides the levels at which the simple effects computed 
simple3way

a moderator of the twoway interaction which is probed 
simpleScale


cvalue

offset value for conditioning 
percvalue

offset value for conditioning 
simpleScaleLabels

decide the labeling of simple effects in tables and plots. 
postHocCorr

one or more of 
scaling

a named vector of the form 
dep_scale

Rescale the dependent variable. It could be 
cluster

a vector of strings naming the clustering variables from 
randomTerms

a list of lists specifying the models random effects. 
correlatedEffects


reml


lrtRandomEffects


plotRandomEffects


cimethod

. 
dfmethod

. 
qq


normTest


normPlot


residPlot


clusterBoxplot


randHist


formula

(optional) the formula to use, see the examples#’ 
data(subjects_by_stimuli) gamlj::gamljMixed( formula = y ~ 1 + cond+( 1subj ), data = subjects_by_stimuli) gamlj::gamljMixed( data = subjects_by_stimuli, dep = "y", factors = "cond", modelTerms = "cond", cluster = "subj", randomTerms=list(list(c("cond","subj"))))
This function returns a list of plots as a ggplot objects produced by the assumptions checking options, such as ‘residPlot’, ‘normPlot’ (for continuous dependent variable models), ‘randHist’ and ‘clusterBoxplot’ (for mixed models).
gamlj_assumptionsPlots(object)
object

a gamlj results object of the class ’gamlj*Results“ 
Marcello Gallucci
This function returns a dataset with the variables in the GAMLj model
transformed according to GAMLj options. It is usefull to run additional
models with other R packages with the same setup used by GAMLj
gamlj_data(object)
object

a gamlj results object of the class ’gamlj*Results’ 
Marcello Gallucci
data('qsport') gmod<gamlj::gamljGlm(formula = performance ~ hours, data = qsport, scaling = c(hours='standardized')) gdata<gamlj_data(gmod) lm(performance ~ hours,data=gdata)
Return the estimated model object of the class lm, lmer, glm depending on the model.
gamlj_model(object)
object

a gamlj results object of the class ’gamlj*Results’ 
Marcello Gallucci
data('qsport') obj<gamlj::gamljGlm( formula = performance ~ hours, data = qsport) model<gamlj_model(obj)
Deprecated. Please use ‘predict()’
gamlj_predict(gobj, re.form = NULL, type = "response")
gobj

a gamlj results object of the class ’gamlj*Results’ 
re.form

if not NULL, specifies the random effect to be included in the computation of the predicted values. Used only for the mixed models. 
type

the type of prediction required. The default is on the scale of the response variables (‘response’); Thus for binomial models the default is to compute the predicted probabilities. ‘link’ gives the scale of the linear predictors; 
Marcello Gallucci
data('qsport') gmod<gamlj::gamljGlm( formula = performance ~ hours, data = qsport) preds<gamlj_predict(gmod)
Deprecated. Please use ‘residuals()’
gamlj_residuals(gobj, type = "response")
gobj

a gamlj results object of the class ’gamlj*Results’ 
type

the type of the residuals for generalized models. The alternatives are: ‘deviance’ (default), ‘pearson’, ‘working’, ‘response’, and ‘partial’. Can be abbreviated., 
stats::predict()
, stats::residuals.lm()
, stats::residuals.glm()
Marcello Gallucci
data('qsport') gmod<gamlj::gamljGlm( formula = performance ~ hours, data = qsport) preds<gamlj_residuals(gmod)
Deprecated, please use ‘simpleffects’ #’
gamlj_simpleEffects( object, variable = NULL, moderator = NULL, threeway = NULL, ... )
object

a gamlj results object of the class ’gamlj*Results’ 
variable

the independent variable name 
moderator

the moderator variable name 
threeway

the name of the additional moderator for three way interactions 
…

any other options accepted by the gamlj_* function 
Marcello Gallucci
This function reestimates a GAMLj model adding a new plot. If no options is passed, extracts the
plots present in the ’gamlj*Results’ object. If one plot is present, it is returned as a ggplot2 object, if more than one is present, a list of plots is returned. FALSE is returned if no plot is present or defined.
## S3 method for class 'gamlj' plot(x, formula = NULL, ...)
x

a gamlj results object of the class ‘gamlj’ 
formula

a right hand side formula specifying the effect to plot, of the form ‘~x’, ’~x*z’ or ‘~xzw’. 
…

all options accepted by a gamlj model function. Relevant for new plots are ‘plotHAxis’, ‘plotSepLines’ and ‘plotSepPlots’ 
Marcello Gallucci
data(qsport) gmod<gamlj::gamljGlm( formula = performance ~ hours, data = qsport) plot(gmod,plotHAxis = 'hours') plot(gmod,formula=~hours)
This is a convenience function to reestimates a GAMLj model adding posthoc tests. If no options is passed, extracts the
posthoc tests tables already in the model results (if any). If new posthoc are defined, the posthoc tests tables
are returned.
posthoc(object, ...) ## S3 method for class 'gamlj' posthoc(object, formula = NULL, ...)
object

a gamlj results object of the class ‘gamlj’ 
…

all options accepted by a gamlj model function. Relevant for new tests are 
formula

a right hand side formula specifying the factors or factors combinations to test, of the form ‘~x+z’, ‘~x:z’ or ’~x*z’. 
Marcello Gallucci
data(fivegroups) fivegroups$Group<factor(fivegroups$Group) gmod<gamlj::gamljGlm( formula = Score ~Group, data = fivegroups) posthoc(gmod,formula =~Group)
Returns predicted values from the estimated model
## S3 method for class 'gamljGlmResults' predict(object, ...) ## S3 method for class 'gamljGzlmResults' predict(object, type = "response", ...) ## S3 method for class 'gamljMixedResults' predict(object, re.form = NULL, type = "response", ...) ## S3 method for class 'gamljGlmMixedResults' predict(object, re.form = NULL, type = "response", ...)
object

a gamlj results object of the class ’gamlj*Results’ 
…

additional arguments for specific predict methods other than the ones specified here. 
type

the type of prediction required. The default is on the scale of the response variables (‘response’); Thus for binomial models the default is to compute the predicted probabilities. ‘link’ gives the scale of the linear predictors; 
re.form

(formula, NULL, or NA) specify which random effects to condition on when predicting. If NULL, include all random effects; if NA or ~0, include no random effects. Used only for the mixed models. 
Marcello Gallucci
data('qsport') gmod<gamlj::gamljGlm( formula = performance ~ hours, data = qsport) preds<predict(gmod)
Returns residuals values from the estimated model
## S3 method for class 'gamljGlmResults' residuals(object, ...) ## S3 method for class 'gamljGzlmResults' residuals(object, type = "deviance", ...) ## S3 method for class 'gamljMixedResults' residuals(object, ...) ## S3 method for class 'gamljGlmMixedResults' residuals(object, type = "deviance", ...)
object

a gamlj results object of the class ’gamlj*Results’ 
…

additional arguments for specific residuals methods. 
type

the type of residuals for generalized models. The alternatives are: ‘deviance’ (default), ‘pearson’, ‘working’, ‘response’, and ‘partial’. Can be abbreviated. Cf. 
Marcello Gallucci
data('qsport') gmod<gamlj::gamljGlm( formula = performance ~ hours, data = qsport) preds<residuals(gmod)
This function calls the generic r.squared
function for each of the models in the list and rbinds the outputs into one data frame
rsquared.glmm(obj)
obj

single model or a list of fitted (generalized) linear (mixed) model objects 
: Jon Lefcheck
Lefcheck, Jonathan S. (2015) piecewiseSEM: Piecewise structural equation modeling in R for ecology, evolution, and systematics. Methods in Ecology and Evolution. 7(5): 573579. DOI: 10.1111/2041210X.12512
This is a convenience function to reestimates a GAMLj model adding simple effect analysis. If no options is passed, extracts the
simple effects tables already in the model results (if any). If new tests are defined, the simple effects tests tables
are returned.
simpleEffects(object, ...) ## S3 method for class 'gamlj' simpleEffects(object, formula = NULL, ...)
object

a gamlj results object of the class ‘gamlj’ 
…

all options accepted by a gamlj model function. Relevant for new tests are 
formula

a right hand side formula specifying the variables to test, of the form ‘~x:z’, ‘~x:z:w’ or ’~x*z’. 
Marcello Gallucci
data(winkel) wicksell$time<factor(wicksell$time) wicksell$group<factor(wicksell$group) gmod<gamlj::gamljMixed( formula = dv ~ 1 +group+ time:group+ time+( 1  subj ), data = wicksell) simpleEffects(gmod,formula =~time:group)
Reestimates a GAMLj model applying new options to the original model
## S3 method for class 'gamljGlmResults' update(object, ...) ## S3 method for class 'gamljGzlmResults' update(object, ...) ## S3 method for class 'gamljMixedResults' update(object, ...) ## S3 method for class 'gamljGlmMixedResults' update(object, ...)
object

of class ’gamlj*Results’ 
…

any parameter to be passed to 
Marcello Gallucci
Got comments, issues or spotted a bug? Please open an issue on GAMLj at github“ or send me an email