GAMLj version ≥ 1.5.0
Mixed Linear Models module of the GAMLj suite for jamovi
The module estimates a mixed linear model with categorial and/or continuous variables, with options to facilitate estimation of interactions, simple slopes, simple effects, post-hoc, etc. In this page you can find some hint to get started with the mixed models module. For more information about how to module works, please check the technical details
The module can estimates REML and ML linear mixed models for any combination of categorical and continuous variables, thus providing an easy way of obtaining multilevel or hierarchical linear models for any combination of independent variables types.
The module provides a parameter estimates of the fixed effects, the random variances and correlation among random coefficients.
Variables definition follows jamovi standards, with categorical independent variables defined in “fixed factors” and continuous independent variables in “covariates”.
The grouping variable is simply set by putting the corresponding
variable(s) into cluster
. In this version, multiple
clustering variables are possible, but not combinations of
classifications ( see Technical Details
).
The actual estimation occurs when the dependent variable, the clustering variable and at least one random coefficient (random effect) has been selected.
REML |
TRUE (default) or FALSE , should the Restricted
ML be used rather than ML
|
Do not run | Do not update results when options are changed. Useful to setup complex models without waiting for each update to conclude |
Fixed Parameters |
TRUE (default) or FALSE , parameters CI in
table
|
Random Variances C.I. |
TRUE or FALSE (default), random effects CI in
table. It could be very slow.
|
Confidence level | a number between 50 and 99.9 (default: 95) specifying the confidence intervals width. |
Activate | Activate the options and fields required to conduct a model comparison analyses |
More Fit Indices | shows AIC and BIC indices for the estimated model |
By default, the model fixed effects terms are filled in automatically for main effects and for interactions with categorical variables.
Interactions between continuous variables or categorical and continuous can be set by clicking the second arrow icon.
Polinomial effects for continuous variables can be added to the model. When a variable is selected in the Components field, a little number appears on the right side of the selection. The number indicates the order of the effect.
By increasing that number before dragging the term into the Model Terms field, one can include any high order effect. Increasing the order number and combining the selection with other variables allows including interactions involving higher order effects of a variable.
Random effects across clustering variables are automatically prepared
by the module following R lmer() standards: term | cluster
indicates that the coefficient associated with term
is
random across cluster
.
By default the module assumes correlated random effects. All the
effects varying across the same cluster variable appearing in the Random coefficients will be correlated. To obtain
a variance component model, select Not
correlated. A custom pattern of correlation can be obtained by
selecting Correlated block. For instance, in
Fig. below, a custom structure has been defined by allowing the
intercept and the effect of x
to be correlated, whereas the
effect of wfac
is independent from the others.
The option LRT for random effects
produces a table of Likelihood Ratio Tests for the random
effects. The table is estimated with lmerTest::ranova
command, documented here.
The test basically compares the likelihood of a model with the
effect
included versus a model with the effect
excluded. For example, x in (1+x|cluster)
means that the
model with (1+x|cluster)
random structure is compared with
a model with 1|cluster)
random structure. If significant,
the model with random effect x
is significantly better (in
terms of likelihood) than the model with (1|cluster)
structure.
Model terms | Show the fixed effects defined in the model in the list of potential random coefficients |
Add |
Show potential random effects in the Components field.
None nothing (more than the fixed effects), the other can
be Main Effects , Up to 2-way interactions,
Up to 3-way interactions, All possible means
showing in the Components list all possible potential
random coefficients.
|
Nesting by formula | Show the clusters in nested formulation (cluster1/cluster2) |
Crossing by formula | Show the clusters in crossed formulation (cluster1:cluster2) |
Effects correlation |
Random effects are assumed to be correlated (Correlated ) or
independent (Not correlated ). If
Correlated by block is selected, additional fields are
shown to create blocks of coefficients correlated within block and
independent between blocks.
|
LRT for Random Effects |
TRUE or FALSE (default), LRT for the random
effects
|
When Model Comparison Activate is flagged, model comparison options become visible. Both for fixed effects
and for random effects.
Two models will be estimated and compared. The current model defined
in by the Model Terms
and the
Random Coefficients
is compared with the the model defined
in the Nested Model
and
Nested Model Random Coefficients
. By default, the
Nested Model
terms are empty and the
Nested Model Random Coefficients
are filled with the full
model random terms, so a model without fixed effects is compared with
the current. When the user defines nested terms, the comparison is
updated.
Consider the following example:
The current model is composed by three main effects (x
,
z
) and the random coefficients for (Intercept)
and x
. The nested model terms are have the same fixed
effects, but it has only the random intercept. Thus, the loglikelihood
ratio test that it is performed to compare the models will test the
significance of the random effect of x
. The output offers a
Table in which each model fit indices and tests are presented, and the
two models comparison test is presented.
It allows to code the categorical variables according to different coding schemas. The coding schema applies to all parameters estimates. The default coding schema is simple, which is centered to zero and compares each means with the reference category mean. The reference category is the first appearing in the variable levels.
Note that all contrasts but dummy guarantee to be centered to zero (intercept being the grand mean), so when involved in interactions the other variables coefficients can be interpret as (main) average effects. If contrast dummy is set, the intercept and the effects of other variables in interactions are estimated for the first group of the categorical IV.
Contrasts definitions are provided in the estimates table. More detailed definitions of the comparisons operated by the contrasts can be obtained by selecting Show contrast definition table.
Differently to standard R naming system, contrasts variables are always named with the name of the factor and progressive numbers from 1 to K-1, where K is the number of levels of the factor.
In reading the contrast labels, one should interpret the
(1,2,3)
code as meaning “the mean of the levels 1,2, and 3
pooled toghether”. If factor levels 1,2 and 3 are all levels of the
factor in the samples, (1,2,3)
is equivalent to “the mean
of the sample”. For example, for a three levels factor, a contrast
labeled 1-(1,2,3)
means that the contrast is comparing the
mean of level 1 against the mean of the sample. For the same factor, a
contrast labeled 1-(2,3)
indicates a comparison between
level 1 mean and the subsequent levels means pooled together.
More details and examples Rosetta store: contrasts.
Continuous variables can be centered, standardized, cluster-based
centered, cluster-based standardized, log-transformed or used as they
are (none
). The default is centered because it makes our lives much easier
when there are interactions in the model, and do not affect the B
coefficients when there are none. Thus, if one is comparing results with
other software that does not center the continuous variables, without
interactions in the model one would find only a discrepancy in the
intercept, because in GAMLj the intercept represents the expected value
of the dependent variable for the average value of the independent
variable. If one needs to unscale the variable, simple select
none.
Centered clusterwise and z-scores clusterwise center each score using the mean of the cluster in which the score belongs. For z-scores clusterwise the score is also divided by the cluster standard deviation. Log applies a simple natural logarithm transformation to the variable.
The same transformations can be applied to the dependent variable by selecting an option in Dependent variable scale.
Covariates conditioning rules how the model is conditioned to different values of the continuous independent variables in the simple effects estimation and in the plots when there is an interaction in the model.
Mean+SD: means that the IV is conditioned to the \(mean\), to \(mean+k \cdot sd\), and to \(mean-k\cdot sd\), where \(k\) is ruled by the white field below the option. Default is 1 SD.
Percentile 50 +offset: means that the IV is conditioned to the \(median\), the \(median+k P\), and the \(median-k\cdot P\), where \(P\) is the offset of percentile one needs. Again, the \(P\) is ruled by the white field below the option. Default is 25%. The default conditions the model to:
\(50^{th}-25^{th}=25^{th}\) percentile
\(50^{th}\) percentile
\(50^{th}+25^{th}=75^{th}\) percentile
The offset should be within 5 and 50.
Note that with either of these two options, one can estimate simple effects and plots for any value of the continuous IV.
Covariates labeling decides which label should be associated with the estimates and plots of simple effects as follows:
Labels produces strings of the form \(Mean \pm SD\).
Values uses the actual values of the variables, after scaling.
Labels+Values produces labels of the
form \(Mean \pm SD=XXXX\), where
XXXX
is the actual value.
Unscaled Values produces labels indicating the actual value (of the mean and sd) of the original variable scale. This can be useful, for instance, when the user needs the estimates to be obtained with centered variables (because there are interactions, for instance), but the plot of the effects is preferred in the original scales of the moderators.
Unscaled Values + Labels as the previous option, but add also the label “Mean” and “SD” to the orginal values.
The Scaling on option decides how the
scaling of the variables handle missing values: First, keep in mind that
the model will be estimated on complete cases, no matter how this option
is set. When there are missing values, however, one can scale each
variable only on the complete cases (the default), or scale
columnwise
. If columnwise
is selected, the
mean and standard deviation of each variable used to scale the scores
are computed with the available data of the variable, independently of
possible missing values in other variables.
Post-hoc tests can be accomplished for the categorical variables groups by selecting the appropriated factor and flag the required tests
Post-hoc tests are implemented based on R package emmeans. All tecnical info can be found here
The “plots” menu allows for plotting main effects and interactions for any combination of types of variables, making it easy to plot interaction means plots, simple slopes, and combinations of them. The best plot is chosen automatically.
By filling in Horizontal axis one obtains the group means of the selected factor or the regression line for the selected covariate.
By filling in Horizontal axis and Separated lines one obtains a different plot depending on the type of variables selected:
By filling in Separate plots one can
probe higher-order interactions. If the selected variable is a factor,
one obtains a two-way graph (as previously defined) for each level of
the “Separate plots” variable. If the selected variable is a covariate,
one obtains a two-way graph (as previously defined) for the
Separate plots
variable centered to conditioning values
selected in the Covariates conditioning
options. Any number of plots can be obtained depending on the order of
the interaction.
By flagging Random effects
one obtains the random
effects estimated values in the plot along with the fixed effects. In
case of multiple cluster variables, the first cluster variable in the
cluster
field of “variable role” panel is used (if it is
included in the model). To change the cluster variable used to plot the
random effects, change the order of the variables in the “variable role”
definition.
Error Bar Definition |
'none' (default), 'ci' , or 'se' .
Use no error bars, use confidence intervals, or use standard errors on
the plots, respectively.
|
Observed scores |
TRUE or FALSE (default), plot raw data along
the predicted values
|
Y-axis observed range |
TRUE or FALSE (default), set the Y-axis range
equal to the range of the observed values.
|
Original scale |
TRUE or FALSE (default), use original scale
for covariates.
|
Varying line types |
TRUE or FALSE (default), use different
linetypes per levels.
|
Random effects |
TRUE or FALSE (default), add predicted values
based on random effect in plot
|
Print the estimate expected means, SE, df and confidence intervals of
the predicted dependent variable by factors in the model. Any
combination available in the model (main effects, interactions,
non-linear terms), can be requested. If the term involves categorical
independent variables, means of each level of the variable are
presented. If the term involves continuous variables, expected means
computed at the levels defined in Covariate Scaling
are
presented.
CI Method | |
Bootstrap rep. | a number bootstrap repetitions. |
DF Method | The method for computing the denominator degrees of freedom and F-statistics. “Satterthwaite” (default) uses Satterthwaite’s method; “Kenward-Roger” uses Kenward-Roger’s method, “lme4” returns the lme4-anova table, i.e., using the anova method for lmerMod objects as defined in the lme4-package |
Predicted | |
Residuals | |
Remove notes | Do not add footnotes to the tables. |
Some worked out examples of the analyses carried out with jamovi GAMLj Mixed models are posted here (more to come)
Some more information about the module specs can be found here