% Ben Bolker % Thu Nov 1 12:42:46 2012

mixed model lecture 1

cc

Licensed under the Creative Commons attribution-noncommercial license. Please share & remix noncommercially, mentioning its origin.

Examples

Glycera

Various responses (survival, cell area) of Glycera (marine worm) cells in response to 4-way factorial combinations of stressors (anoxia, copper, salinity, hydrogen sulfide)

plot of chunk glycplot1

plot of chunk glycplot2

Arabidopsis

Response of Arabidopsis fruiting success to nutrients and simulated herbivory (clipping) across genotypes/populations/regions

plot of chunk arabplot

Singing mouse

Response of singing mouse to conspecific and heterospecific playback experiments

plot of chunk singingmouse

others

plot of chunk culcplot

“classical” vs “modern” approaches to ANOVA

Classical: “method of moments” estimation

Modern: computational

What is a random effect?

(See @gelman_analysis_2005)

Philosophical:

Pragmatic/computational:

To Bayesians, the difference between fixed and random is much simpler and more pragmatic: do we add a hyperparameter to the model to characterize the estimates, or estimate them separately (= infinite variance)?

dimensions of data size

Examples

Definition of model and (marginal) likelihood

A useful (if somewhat technical) way to define a plain-vanilla linear model (normally distributed residuals, no random effects) is

\[ Y_i \sim \mbox{Normal}(\mu_i,\sigma^2); \mu = X \beta \] where \( X \) is the design matrix, \( \beta \) are the coefficients (all fixed effects). This is equivalent to, but more useful than, the other standard notation \( Y_i \sim X \beta + \epsilon \), \( \epsilon \sim \mbox{Normal}(0,\sigma^2) \) because some of the distributions we want to work can't simply be added to the expected response …

When we go to random-effects models, we add another level to the model:

\[ Y_i \sim \mbox{Normal}(\mu_i,\sigma^2) \] \[ \mu = X \beta + Z u \] \[ u \sim \mbox{MVN}(0,\Sigma(\theta)) \] where \( Z \) is the random-effects design matrix; \( u \) is the vector of random effects; and \( \theta \) is a vector of parameters that determines the variance-covariance matrix \( \Sigma \) of the random effects. (For example, for a simple intercept-only, model, \( \theta \) might just be the among-block variance.)

GLMs look like this: \[ Y_i \sim \mbox{Distrib}(\mu_i,\phi); \mu = g^{-1}(X \beta) \] where \( \mbox{Distrib} \) is some specified distribution (e.g. binomial or Poisson); \( \phi \) is an optional scale parameter; and \( g^{-1} \) is the inverse link function (e.g. logistic or exponential, discussed further below).

GLMMs combine the inverse-link and arbitrary-distribution stuff with random effects: essentially, \[ \mu = g^{-1}(X \beta + Z u) \] with \( Y \) and \( u \) defined as above.

Because random effects are random variables, the likelihood (or more precisely the marginal likelihood) of a set of parameters balances the probability of the data (\( x \)) given the fixed parameters \( \beta \) and a particular value of the random effect (\( u \)) with the probability of that value of the random effect given the variance of the random effects (\( \sigma \)), integrated over all possible values of \( \sigma \):

\[ L(x|\beta,\sigma) = \int L(x|\beta,u) \cdot L(u|\sigma) \, d\sigma \]

The Bayesian posterior distribution is basically the same, except that we include a prior distribution (and we rarely have to worry about the doing the integral explicitly)

Restricted maximum likelihood (REML)

While maximum likelihood estimation (finding the \( \beta \), \( \theta \) (and possibly \( u \)) that maximize the expression above) is a very powerful and coherent approach, it turns out to give biased estimates of the variances.

A heuristic explanation is that it estimates the variances as though the maximum likelihood estimates of the fixed-effect parameters were correct, which underestimates the variability in the data.

Two useful special cases of REML are (1) dividing sample sums of squares by \( n-1 \) rather than \( n \) to get an unbiased estimate of the sample variance and (2) doing a paired \( t \) test by explicitly computing the means and variances of the differences in the pairs.

Technically, REML consists of finding a linear combination of the data that exactly reduces the fixed-effect estimates to zero, then estimating the random-effects part of the model on those data.

Important things to know about REML:

Avoiding MM

LM reminders

y ~ f  ## anova
y ~ x  ## regression (implicit intercept term)
y ~ x - 1  ## regression through origin (or y ~ x+0)
y ~ f1:f2  ## interaction only
y ~ f1/f2  ## f2 nested in f1
y ~ f * x  ## interaction between factor and predictor (ANCOVA)
y ~ poly(x, 3)  ## cubic
y ~ ns(x, 3)  ## spline with 3 knots: library(splines)

For most random-effects packages in R, | represents a grouping factor: 1|grp means variation in the intercept among groups, x|grp means variation in the slopes (and implicitly also in the intercepts), 1|grp1/grp2 means variation in the intercepts among group 1 and also among levels of group 2 within a group-1 unit.

GLM reminders

References