# Fixed/Random Effects GLM for fMRI

As I understand it, this is a fixed-effects GLM (as could be used in analyzing the results of an fMRI experiment):

$$Y = X\beta + \epsilon$$

I assume that $Y$ is a matrix of all the data (voxels $\times$ time points) concatenated diagonally over all subjects, and padded with zeroes. Consequently the estimated $\beta$ should be a matrix of contrasts (over regressor and participant). I have repeatedly read that this allows us to "compare the group effect to the within-subject variability".

• How?

Apparently to capture effects that differ in spatial pattern and/or magnitude over participants, we need a random-effects model. As I understand it, this looks like this:

$$Y = X\beta + \epsilon$$ $$\beta = X'\beta' + \epsilon'$$

• What kind of matrix is $X'$?
• Why do we need this? doesn't $\beta$ already contain participant-specific estimates - which we can use to get $\mu$ and $\sigma$ for every voxel?

## 2 Answers

This is a pretty broad question - I would basically translate this into: what is a GLM, and what is a mixed model. First of all, you write that you want to fit a GLM, but I suspect you mean LM, because the formula

$$Y = X\beta + \epsilon$$

would typically denote an LM. For the GLM, we would have an additional link function.

In the formula above, $Y$ is your response, $X$ are your predictors (design matrix), and $\beta$ are the regression coefficients for these predictors (contrasts if categorical).

Your notation for a random-effects model is a bit unorthodox (not sure from where this is taken), but I would suspect

$$Y = X\beta + \epsilon$$ $$\beta = X'\beta' + \epsilon'$$

means that you want to fit a so-called random slope model, in which the regression coefficients / contrasts can differ for each grouping factor. The assumption of the random slope model is that differences in $\beta$ between the groups are drawn from a normal distribution $\epsilon'$, which is the between-group-variability. So the final entire vector of predictors $\beta$ is composed of the overall $\beta'$ and the random effects $\epsilon'$.

In general, I'm not sure if this notation is exceedingly useful to understand how a mixed model works - I would suggest to read start with a general textbook or tutorial about mixed models.

• A simple tutorial in R is Bates, D.; Mächler, M.; Bolker, B. & Walker, S. (2014) Fitting linear mixed-effects models using lme4.
• A more statistical reference is Gelman, A. & Hill, J. (2006) Data analysis using regression and multilevel/hierarchical models. Cambridge University Press, in particular ch 11,12
• To get a basic explanation about the computational methods, you could look at Bates, D. M. (2010) lme4: Mixed-effects modeling with R.

Of course there are many other good books, it depends on your field and what level of mathematics you are looking for.

• can you recommend such a tutorial? – TheChymera Jan 26 '16 at 3:07
• I have added a few references. – Florian Hartig Jan 26 '16 at 10:47

As this question is specifically related to fMRI, I think I get what you mean with random-effects model, which is the usually adopted one for fMRI group analysis (second-level). There are 2 levels of modeling, the first one (first GLM Y=Xβ+ϵ) refers to an individual (single-subject) analysis, where you fit the fMRI signal of every brain voxel (Y). The second one (β=X′β′+ϵ′) represents instead a subsequent group analysis, where you fit the parameters which are output from the first model (betas), i.e. the brain activation maps of multiple subjects (to be simplistic but clear). To answer your questions: - X' is the design matrix of the group analysis (e.g., one sample t-test, two sample t-test, etc). - We need the second equation for the group analysis. Every Beta vector contains a voxel effect size (activation) across subjects.