Mixed effects algebra#
Starter simulations#
We’ll take a simulation-based approach to understanding mixed effects and how they perform. We’ll address questions including:
Is the 2-stage summary statistics approach valid?
Is is as powerful as a full mixed effects model?
What is the power and false positive rate of different approaches and implementations?
What happens when we violate some of the assumptions?
First, we’ll generate some data under a simple mixed effects scenario (a simple generative model) and explore some plots of the data. We’ll fit the model using several mixed effects models:
Matlab’s fitlme
CANlab’s glmfit_multilevel
CANlab’s igls and rigls
The live script below also reviews the main elements of the matrix algebra underlying mixed effects, using the notation in [Lindquist et al. 2012](papers/Lindquist_2012_variance components_in_multi-level_GLM.pdf). The model describes the basic framework and Iterative Generalized Least Squares, one way of estimating variance components. Other models have a similar structure but differ in some details (e.g., Bates et al. 2015 for LMER in R).
Activities#
Identify and compare residual variance terms, slope estimates, t-values across models
Modify the code to generate one or more continuous predictors instead of categorical/experimental ones.
Turn the data-generation script into a function, so that you can efficiently simulate power and false positive rates using repeated simulations – two key properties of any statistical model.
Answer key For a pre-cooked answer (Matlab), see: Download a Matlab data sim function
But…don’t peek! Do it yourself!!!