This script uses a subset of data reported in Fühner et al. (2021). To circumvent delays associated with model fitting we work with models that are less complex than those in the reference publication. All the data to reproduce the models in the publication are used here, too; the script requires only a few changes to specify the more complex models in the article.
The script is structured in three main sections:
Setup with reading and examining the data, plotting the main results, and specifying the contrasts for the fixed factor Test
a demonstration of model complexification to determine a parsimonious random-effect structure appropriate for and supported by the data, including also a quite elaborate demonstration of principle component analyses (PCAs) of levels (scores) and effects,
specification of nested fixed effects or interactions in the levels of another, superordinate factors.
We center age at 8.5 years and compute z-scores for each Test. With these variables the data frame df contains all variables used for the final model in the original publication.
The preprocessing steps above are also packaged as SMLP2026.fggk21_preprocessed(), so that other pages (e.g. the contrast-coding tutorial) can reuse them without repeating the code.
2.2 Extract a stratified subsample
For the purpose of the tutorial, we extract a random sample of 1000 boys and 1000 girls. Child, School, and Cohort are grouping variables. Traditionally, they are called random factors because the units (levels) of the factor are assumed to be a random sample from the population of their units (levels).
Cohort has only nine “groups” and could have been included as a set of polynomical fixed-effect contrasts rather than a random factor. This choice warrants a short excursion: The secular trends are very different for different tests and require the inclusion of interaction terms with Test contrasts (see Figure 4 in (Fühner et al., 2021). The authors opted to absorb these effects in cohort-related variance components for the Test contrasts and plan to address the details of secular changes in a separate analysis.
For complex designs, when they are in the theoretical focus of an article, factors and covariates should be specified as part of the fixed effects. If they are not in the theoretical focus, but serve as statistical control variables, they could be put in the RES - if supported by the data.
Stratified sampling: We build a table with one row per child, sample 1000 boys and 1000 girls from it without replacement, and then extract all of the sampled children’s test scores from df. Sampling whole children – rather than individual scores – preserves the within-child structure that by-Child random slopes rely on. This procedure is packaged as SMLP2026.fggk21_teaching_sample(); it uses a StableRNG with a fixed seed so that the stratification is reproducible across Julia versions (pass a different seed for a different pattern of results). The contrast-coding tutorial uses the same subsample, so estimates are directly comparable between the two pages.
The core results of the article are reported in Figure 2 of Fühner et al. (2021). In summary:
Main effects of age and Sex: There are developmental gains in the ninth year of life; boys outperform girls. There is no main effect of Test because of z-scoring.
Interactions of Test and age: Tests differ in how much children improve during the year (i.e., the magnitude of developmental gain), that is slopes depend on Test.
Interactions of Test and Sex: The sex difference is test dependent, that is the difference between the slopes depends on Test.
The most distinctive result is the absence of evidence for an age x Sex x Test interaction, that is the slopes for boys and girls are statistically parallel for each of the five tests.
Figure 1: Age trends by sex for each Test for the full data set
Figure 1 shows performance differences for the full set of data between 8.0 and 9.2 years by sex in the five physical fitness tests presented as z-transformed data computed separately for each test.
PowerLOW = power of lower limbs (i.e., standing long jump test),
PowerUP = power of upper limbs (i.e., ball push test),
SD = standard deviation. Points are binned observed child means; lines are simple regression fits to the observations.
What do the results look like for the stratified subsample? Here the parallelism is much less clear. In the final LMM we test whether the two regression lines in each of the five panels are statistically parallel for this subset of data. That is, we test the interaction of Sex and age as nested within the levels of Test. Most people want to know the signficance of these five Sex x age interactions.
The theoretical focus of the article, however, is on comparisons between tests displayed next to each other. We ask whether the degree of parallelism is statistically the same for Endurance and Coordination (H1), Coordination and Speed (H2), Speed and PowerLOW (H3), and PowerLow and PowerUP (H4). Hypotheses H1 to H4 require Sequential Difference contrasts c1 to c4 for Test; they are tested as fixed effects for`H1 x age x Sex, H2 x age x Sex, H3 x age x Sex, and H4 x age x Sex.
Figure 2: Age trends by sex for each Test for the stratified sample
Figure 2 Performance differences for subset of data between 8.0 and 9.2 years by sex in the five physical fitness tests presented as z-transformed data computed separately for each test.
PowerLOW = power of lower limbs (i.e., standing long jump test),
PowerUP = power of upper limbs (i.e., ball push test),
SD = standard deviation. Points are binned observed child means; lines are simple regression fits to the observations.
2.3.2 Regression on age by Sex for each Test
Another set of relevant statistics are the slopes for the regression of performance on age for boys and girls in each of the five tests. The lines in Figures 1 and 2, however, are computed directly from the raw data with the linear() command.
SeqDiffCoding was used in the publication. This specification tests pairwise differences between the five neighboring levels of Test, that is:
H1: Star_r - Run (2-1)
H2: S20_r - Star_r (3-2)
H3: SLJ - S20_r (4-3)
H4: BPT - SLJ (5-4)
The levels were sorted such that these contrasts map onto four a priori hypotheses; in other words, they are theoretically motivated pairwise comparisons. The motivation also encompasses theoretically motivated interactions with Sex. The order of levels can also be explicitly specified during contrast construction. This is very useful if levels are in a different order in the dataframe.
The first command recodes names indicating the physical fitness components used in the above figures and tables back to the shorter actual test names. This reduces clutter in LMM outputs.
recode!( dat.Test,"Endurance"=>"Run","Coordination"=>"Star_r","Speed"=>"S20_r","PowerLOW"=>"SLJ","PowerUP"=>"BPT",)contrasts =Dict{Symbol,Any}(nm =>SeqDiffCoding() for nm in (:Test, :Sex))
See the contrast-coding tutorial for why sequential-difference contrasts are not orthogonal and what that implies for the interpretation of correlation parameters between neighboring contrasts, as well as for alternative contrast schemes for these data; contrast coding of visual-attention effects works through the general options on a four-level factor.
3 Model complexification
We fit and compare three LMMs with the same fixed-effect structure but increasing complexity of the random-effect structure for School. We ignore the other two random factors Child and Cohort to avoid undue delays when fitting the models.
LMM m_ovi: allowing only varying intercepts (“Grand Means”);
LMM m_zcp: adding variance components (VCs) for the four Test contrasts, Sex, and age to LMM m_ovi, yielding the zero-correlation parameters LMM;
LMM m_cpx: adding correlation parameters (CPs) to LMM m_zcp; yielding a complex LMM.
In a final part illustrate how to check whether the complex model is supported by the data, rather than leading to a singular fit and, if supported by the data, whether there is an increase in goodness of fit associated with the model complexification.
3.1 LMM m_ovi
In its random-effect structure (RES) we only vary intercepts (i.e., Grand Means) for School (LMM m_ovi), that is we allow that the schools differ in the average fitness of its children, average over the five tests.
It is well known that such a simple RES is likely to be anti-conservative with respect to fixed-effect test statistics.
m_ovi =let f =@formula zScore ~1+Test* Sex * a1 + (1| School)fit(MixedModel, f, dat; contrasts, progress)end
Is the model singular (overparameterized, degenerate)? In other words: Is the model not supported by the data?
issingular(m_ovi)
false
Models varying only in intercepts are almost always supported by the data.
3.2 LMM m_zcp
In this LMM we allow that schools differ not only in GM, but also in the size of the four contrasts defined for Test, in the difference between boys and girls (Sex) and the developmental gain children achieve within the third grade (age).
We assume that there is covariance associated with these CPs beyond residual noise, that is we assume that there is no detectable evidence in the data that the CPs are different from zero.
m_zcp =let f =@formula( zScore ~1+Test* Sex * a1 +zerocorr(1+Test+ Sex + a1 | School) )fit(MixedModel, f, dat; contrasts, progress)end
Depending on sampling, this model estimating variance components for School may or may not be supported by the data.
issingular(m_zcp)
true
3.3 LMM m_cpx
In the complex LMM investigated in this sequence we give up the assumption of zero-correlation between VCs.
m_cpx =let f =@formula( zScore ~1+Test* Sex * a1 + (1+Test+ Sex + a1 | School) )fit(MixedModel, f, dat; contrasts, progress)end
We also need to see the VCs and CPs of the random-effect structure (RES).
VarCorr(m_cpx)
Column
Variance
Std.Dev
Corr.
School
(Intercept)
0.0876384
0.2960378
Test: Star_r
0.0971150
0.3116328
+0.11
Test: S20_r
0.0356897
0.1889171
+0.14
-0.77
Test: SLJ
0.0059103
0.0768787
-0.59
-0.35
-0.01
Test: BPT
0.0314018
0.1772055
-0.54
+0.01
+0.30
-0.02
Sex: Girls
0.2341024
0.4838413
-0.16
+0.06
+0.12
+0.45
-0.04
a1
0.6565138
0.8102554
-0.10
+0.05
-0.10
+0.54
+0.13
-0.03
Residual
0.7306303
0.8547691
issingular(m_cpx)
false
The complex model may or may not be supported by the data.
3.4 Model comparisons
The singularity checks depend on the subsample: with the present one, m_ovi and m_cpx are supported by the data, while the zero-correlation model m_zcp is singular (one of its variance components is estimated as zero). Does model complexification also increase the goodness of fit or are we only fitting noise?
3.4.1 LRT and goodness-of-fit statistics
As the thee models are strictly hierarchically nested, we compare them with a likelihood-ratio tests (LRT) and AIC and BIC goodness-of-fit statistics derived from them.
These statistics will depend on sampling. In general, smaller deviance, AIC, and BIC indicate an improvement in goodness of fit. Usually, χ² should be larger than the associated degrees of freedom; for AIC and BIC the decrease should amount to more than 5, according to some literature. Severity of meeting these criteria increases from deviance to AIC to BIC. Therefore, it is not always the case that the criteria are unanimous in their verdict. Basically, the more confirmatory the analysis, the more one may go with deviance and AIC; for exploratory analyses the BIC is probably a better guide. There are grey zones here.
3.4.2 Comparing fixed effects of m_ovi, m_zcp, and m_cpx
We check whether enriching the RES changed the significance of fixed effects in the final model.
The three models usually do not differ in fixed-effect estimates. For main effects of age and Sex, z-values decrease strongly with the complexity of the model (i.e., standard errors are larger). For other coefficients, the changes are not very large and not consistent.
In general, dropping significant variance components and/or correlation parameters may lead to anti-conservative estimates of fixed effects (e.g., Schielzeth & Forstmeier, 2008). Basically, some of the variance allocated to age and Sex in LMM m_ovi could also be due to differences between schools. This ambiguity increased the uncertainty of the respective fixed effects in the other two LMMs.
3.5 Fitting an overparameterized LMM
The complex LMM was not overparameterized with respect to School, because there are over 400 schools in the data. When the number of units (levels) of a grouping factor is small relative to the number of parameters we are trying to estimate, we often end up with an overparameterized / degenerate random-effect structure.
As an illustration, we fit a full CP matrix for the Cohort. As there are only nine cohorts in the data, we may be asking too much to estimate 5*6/2 = 15 VC/CP parameters.
m_cpxCohort =let f =@formula zScore ~1+Test* a1 * Sex + (1+Test| Cohort)fit(MixedModel, f, dat; contrasts, progress)end
VarCorr(m_cpxCohort)
Column
Variance
Std.Dev
Corr.
Cohort
(Intercept)
0.0002056
0.0143393
Test: Star_r
0.0015819
0.0397730
-0.54
Test: S20_r
0.0046825
0.0684287
-0.51
-0.45
Test: SLJ
0.0025294
0.0502930
+0.97
-0.31
-0.71
Test: BPT
0.0022986
0.0479434
-0.64
+0.99
-0.33
-0.44
Residual
0.9219180
0.9601656
issingular(m_cpxCohort)
true
The model is overparameterized, with correlation parameters estimated close to ±1. How about the zero-correlation parameter (zcp) version of this LMM?
m_zcpCohort =let f =@formula( zScore ~1+Test* a1 * Sex +zerocorr(1+Test| Cohort) )fit(MixedModel, f, dat; contrasts, progress)end
issingular(m_zcpCohort)
true
This zcpLMM is also singular: with the present subsample, all five VCs are estimated as zero. This raises the possibility that LMM m_oviCohort might fit as well as LMM m_zcpCohort.
m_oviCohort =let f =@formula zScore ~1+Test* a1 * Sex + (1| Cohort)fit(MixedModel, f, dat; contrasts, progress)end
issingular(m_oviCohort)
true
With the present subsample even this varying-intercepts model estimates the Cohort VC as zero — there is essentially no cohort-related variance left in the reduced data. Does LMM m_zcpCohort fit noise relative to the LMM m_oviCohort?
Indeed, adding VCs is fitting noise. Again, the goodness of fit statistics unanimously favor the selection of the LMM m_oviCohort.
Not shown here, but the Cohort-related VCs for the Test contrasts could be estimated reliably for the full data. Thus, the small number of cohorts does not necessarily prevent the determination of reliable differences between tests across cohorts. What if we include VCs and CPs related to random factors Child and School?
3.6 Fitting the published LMM m1 to the reduced data
Warning
The following LMMs m1, m2, etc. take a bit longer to fit (a few minutes each on a recent laptop). As elsewhere in these materials, the rendered page restores the fits from a cache via fit_or_restore, so re-rendering is fast; delete the corresponding files under fits/ to force a fresh fit.
LMM m1 reported in Fühner et al. (2021) included random factors for School, Child, and Cohort. The RES for School was specified like in LMM m_cpx. The RES for Child included VCs and CPs for Test, but not for linear developmental gain in the ninth year of life a1 or Sex; they are between-Child effects.
The RES for Cohort included only VCs, no CPs for Test. The parsimony was due to the small number of nine levels for this grouping factor.
Here we fit this LMM m1 for the reduced data. For a different subset of similar size on MacBook Pro [13 | 15 | 16] this took [303 | 250 | 244 ] s; for LMM m1a (i.e., dropping 1 school-relate VC for Sex), times are [212 | 165 | 160] s. The corresponding lme4 times for LMM m1 are [397 | 348 | 195].
Finally, times for fitting the full set of data –not in this script–, for LMM m1are [60 | 62 | 85] minutes (!); for LMM m1a the times were [46 | 48 | 34] minutes. It was not possible to fit the full set of data with lme4; after about 13 to 18 minutes the program stopped with: Error in eval_f(x, ...) : Downdated VtV is not positive definite.
m1 =let f =@formula( zScore ~1+Test* a1 * Sex + (1+Test+ a1 + Sex | School) + (1+Test| Child) +zerocorr(1+Test| Cohort) )fit(MixedModel, f, dat; contrasts, progress)end
m1
Est.
SE
z
p
σ_Child
σ_School
σ_Cohort
(Intercept)
-0.0274
0.0186
-1.47
0.1405
0.5780
0.2141
0.0000
Test: Star_r
-0.0104
0.0323
-0.32
0.7474
0.6964
0.3888
0.0000
Test: S20_r
-0.0277
0.0317
-0.87
0.3818
0.5991
0.3225
0.0377
Test: SLJ
0.0038
0.0270
0.14
0.8879
0.4485
0.2712
0.0242
Test: BPT
0.0067
0.0285
0.23
0.8152
0.7018
0.2425
0.0187
a1
0.2359
0.0520
4.54
<1e-05
0.1752
Sex: Girls
-0.4194
0.0308
-13.62
<1e-41
0.1264
Test: Star_r & a1
0.1165
0.0866
1.35
0.1786
Test: S20_r & a1
0.0393
0.0814
0.48
0.6295
Test: SLJ & a1
-0.0911
0.0738
-1.23
0.2172
Test: BPT & a1
0.2680
0.0844
3.18
0.0015
Test: Star_r & Sex: Girls
0.3112
0.0510
6.10
<1e-08
Test: S20_r & Sex: Girls
-0.0674
0.0477
-1.41
0.1578
Test: SLJ & Sex: Girls
-0.0748
0.0433
-1.73
0.0841
Test: BPT & Sex: Girls
-0.3128
0.0496
-6.31
<1e-09
a1 & Sex: Girls
-0.0599
0.1023
-0.59
0.5581
Test: Star_r & a1 & Sex: Girls
0.0486
0.1731
0.28
0.7791
Test: S20_r & a1 & Sex: Girls
-0.1097
0.1617
-0.68
0.4974
Test: SLJ & a1 & Sex: Girls
-0.1900
0.1469
-1.29
0.1959
Test: BPT & a1 & Sex: Girls
0.1881
0.1683
1.12
0.2636
Residual
0.5564
VarCorr(m1)
Column
Variance
Std.Dev
Corr.
Child
(Intercept)
0.3340612
0.5779802
Test: Star_r
0.4849610
0.6963914
+0.13
Test: S20_r
0.3589109
0.5990917
+0.00
-0.46
Test: SLJ
0.2011919
0.4485442
-0.04
-0.10
-0.42
Test: BPT
0.4925463
0.7018164
-0.33
+0.11
-0.13
-0.15
School
(Intercept)
0.0458521
0.2141311
Test: Star_r
0.1511322
0.3887573
+0.02
Test: S20_r
0.1040291
0.3225354
+0.11
-0.61
Test: SLJ
0.0735391
0.2711809
-0.15
-0.13
-0.42
Test: BPT
0.0588117
0.2425113
-0.13
+0.01
+0.12
-0.41
a1
0.0306948
0.1751994
+0.29
-0.19
+0.03
+0.61
+0.18
Sex: Girls
0.0159679
0.1263641
-0.58
+0.33
+0.02
+0.30
-0.09
+0.18
Cohort
(Intercept)
0.0000000
0.0000000
Test: Star_r
0.0000000
0.0000000
.
Test: S20_r
0.0014220
0.0377094
.
.
Test: SLJ
0.0005858
0.0242029
.
.
.
Test: BPT
0.0003508
0.0187294
.
.
.
.
Residual
0.3095329
0.5563568
issingular(m1)
true
Depending on the random number seed for the stratified sampling, LMM m1 may or may not be supported by the data; with the present subsample it is singular.
We also fit an alternative parameterization, estimating VCs and CPs for Test scores rather than Test effects by replacing the 1 + ... in the RE terms with 0 + ....
m2 =let f =@formula( zScore ~1+Test* a1 * Sex + (0+Test+ a1 + Sex | School) + (0+Test| Child) +zerocorr(0+Test| Cohort) )fit(MixedModel, f, dat; contrasts, progress)end
m2
Est.
SE
z
p
σ_Child
σ_School
σ_Cohort
(Intercept)
-0.0286
0.0192
-1.49
0.1373
Test: Star_r
-0.0103
0.0338
-0.31
0.7596
0.8483
0.3255
0.0294
Test: S20_r
-0.0312
0.0370
-0.84
0.3987
0.8275
0.3074
0.0617
Test: SLJ
0.0082
0.0342
0.24
0.8092
0.7861
0.2606
0.0258
Test: BPT
0.0062
0.0291
0.21
0.8305
0.7546
0.2542
0.0000
a1
0.2327
0.0521
4.47
<1e-05
0.1717
Sex: Girls
-0.4198
0.0308
-13.62
<1e-41
0.1275
Test: Star_r & a1
0.1156
0.0870
1.33
0.1839
Test: S20_r & a1
0.0250
0.0821
0.30
0.7612
Test: SLJ & a1
-0.0670
0.0747
-0.90
0.3695
Test: BPT & a1
0.2635
0.0845
3.12
0.0018
Test: Star_r & Sex: Girls
0.3110
0.0510
6.10
<1e-08
Test: S20_r & Sex: Girls
-0.0692
0.0477
-1.45
0.1467
Test: SLJ & Sex: Girls
-0.0726
0.0432
-1.68
0.0931
Test: BPT & Sex: Girls
-0.3134
0.0496
-6.32
<1e-09
a1 & Sex: Girls
-0.0579
0.1023
-0.57
0.5714
Test: Star_r & a1 & Sex: Girls
0.0486
0.1731
0.28
0.7788
Test: S20_r & a1 & Sex: Girls
-0.0988
0.1616
-0.61
0.5409
Test: SLJ & a1 & Sex: Girls
-0.2008
0.1467
-1.37
0.1710
Test: BPT & a1 & Sex: Girls
0.1894
0.1682
1.13
0.2602
Test: Run
0.8177
0.3007
0.0000
Residual
0.4232
issingular(m2)
true
Depending on the random number generator seed, the model may or may not be supported in the alternative parameterization of scores. The fixed-effects profile is not affected (see the model comparisons below).
VarCorr(m2)
Column
Variance
Std.Dev
Corr.
Child
Test: Run
0.6685769
0.8176655
Test: Star_r
0.7196973
0.8483498
+0.46
Test: S20_r
0.6848056
0.8275298
+0.47
+0.56
Test: SLJ
0.6179891
0.7861228
+0.51
+0.56
+0.65
Test: BPT
0.5694333
0.7546081
+0.17
+0.32
+0.32
+0.37
School
Test: Run
0.0904482
0.3007460
Test: Star_r
0.1059671
0.3255260
+0.23
Test: S20_r
0.0944839
0.3073823
+0.45
+0.48
Test: SLJ
0.0679284
0.2606308
+0.54
+0.41
+0.55
Test: BPT
0.0646129
0.2541907
+0.37
+0.26
+0.51
+0.56
a1
0.0294933
0.1717361
+0.14
-0.10
-0.06
+0.55
+0.74
Sex: Girls
0.0162487
0.1274703
-0.85
-0.40
-0.42
-0.16
-0.25
+0.19
Cohort
Test: Run
0.0000000
0.0000000
Test: Star_r
0.0008625
0.0293682
.
Test: S20_r
0.0038116
0.0617382
.
.
Test: SLJ
0.0006674
0.0258334
.
.
.
Test: BPT
0.0000000
0.0000000
.
.
.
.
Residual
0.1790652
0.4231610
3.7 Principle Component Analysis of Random Effect Structure (rePCA)
The ìssingular() command is sort of a shortcut for a quick inspection of the principle components (PCs) of the variance-covariance matrix of the RES. With the MixedModels.PCA() command, we also obtain information about the amount of cumulative variance accounted for as we add PCs.
The output also provides PC loadings which may facilitate interpretation of the CP matrices (if estimated). See Fühner et al. (2021) for an application.
3.8 Effects in RES
For every random factor, MixedModels.PCA() extracts as many PCs as there are VCs. Therefore, the cumulation of variance across PCs within a random factor will always add up to 100% – at the latest with the last VC, but, in the case of overparameterized LMMs, the ceiling will be reached earlier. The final PCs are usually quite small.
PCs are extracted in the order of the amount of unique variance they account for. The first PC accounts for the largest and the final PC for the least amount of variance. The number the PCs with percent variance above a certain threshold indicates the number of weighted composites needed and reflects the dimensionality of the orthogonal space within which (almost) all the variance can be accounted for. The weights for forming composite scores are the listed loadings. For ease of interpretation it is often useful to change the sign of some composite scores.
The PCA for LMM m1 shows that each of the five PCs for Child accounts for a non-zero percent of unique variance.
For School fewer than seven PCs have unique variance. The exact number depends on sampling. The overparameterization of School might be resolved when the CPs for Sex are dropped from the LMM.
Cohort was estimated with CPs forced to zero. Therefore, the VCs were forced to be orthogonal; they already represent the PCA solution. However, depending on sampling, not all PCs may be identified for this random factor either.
Importantly, again depending on sampling, a non-singular fit does not imply that unique variance is associated with all PCs (i.e., not for last PC for School). Embrace uncertainty!
Now lets looks at the PCA results for the alternative parameterization of LMM m2. It is important to note that the reparameterization to base estimates of VCs and CPs on scores rather than effects applies only to the Test factor (i.e., the first factor in the formula); VCs for Sex and age refer to the associated effects.
Depending on sampling, the difference between LMM m1 and LMM m2 may show that overparameterization according to PCs may depend on the specification chosen for the other the random-effect structure.
Note
For the complete data, all PCs had unique variance associated with them.
3.9 Summary of results for stratified subset of data
Returning to the theoretical focus of the article, the significant main effects of age and Sex are replicated, as are the interaction between age and the c4 contrast and the interactions between Sex and two test contrasts (c1, c4). The remaining contrast interactions reported for the full data do not reach significance in this subsample. Obviously, the subset of data is much noisier than the full set.
4Age x Sex nested in levels of Test
In this final LMM, we test post-hoc five age x Sex interactions by nesting the interaction in the levels of Test. As this LMM m2_nested is a reparameterization of LMM m2.
The results show that none of the interactions in the panels of Figure 2 is significant. The size and direction of interaction effects correspond with what is shown in Figure 2.
In principle, the models should yield the same deviance. When models are not supported by the data, that is for singular models, there may be small differences between deviances for these reparameterizations. During optimization such models search for the absolute minimum in a very shallow surface and may end up in a local minimum instead.
4.1 See Also
Mixed Models Tutorial: Contrast Coding — applies a full range of contrast schemes (effect, Helmert, hypothesis, PCA-based) to the same Emotikon dataset.
MixedModels.jl cheatsheet — a tour of the extractor functions for inspecting a fitted model, formerly a section of this page.
Fühner, T., Granacher, U., Golle, K., & Kliegl, R. (2021). Age and sex effects in physical fitness components of 108,295 third graders including 515 primary schools and 9 cohorts. Scientific Reports, 11(1). https://doi.org/10.1038/s41598-021-97000-4
Schielzeth, H., & Forstmeier, W. (2008). Conclusions beyond support: Overconfident estimates in mixed models. Behavioral Ecology, 20(2), 416–420. https://doi.org/10.1093/beheco/arn145
4.2 Exercises
Read the PCA. Inspect the principal-components decomposition of the random effects. How many components carry most of the variance, and how does that inform which random-effects terms to keep?
NoteSolution
If the first few components account for nearly all of the random-effects variance, the remaining dimensions are effectively redundant — the data do not support a full-rank random-effects covariance. That is the quantitative basis for reducing the random-effects structure (e.g. dropping near-zero components or correlation parameters) rather than guessing.
Add a comparison. Add a contrast for the Test factor that encodes a comparison you find substantively interesting, refit, and check whether it changes the conclusions about the age-by-sex interaction.
NoteSolution
Because re-coding a factor does not change the model fit, the omnibus conclusions (and the age-by-sex interaction) are unaffected; what changes is which specific comparison each Test coefficient reports. Use this to confirm that your substantive comparison is or is not significant without disturbing the rest of the model. See Mixed Models Tutorial: Contrast Coding.
This page was rendered from git revision 29e8d33
using Quarto 1.10.18 and Julia 1.12.7.