Lecture 45—Friday, April 7, 2006
What was covered?
- Incorporating level-2 predictors in multilevel models
- Marginal (population-averaged) models versus conditional (subject-specific) models
Terminology defined
Level-2 predictors in multilevel models
- Using the larval development data set we have thus far considered the following three multilevel models.
- An unconditional means model—a model in which there are no predictors, just an intercept at level 1. The level-2 equation consists of a single equation for the intercept with no predictors. This model estimates a single overall population mean for lnPLD. Individual species means are assumed to be just random deviations about that population mean.
- A random intercepts model. A linear equation appears at level 1 relating lnPLD to lntemp. All species are assumed to share a common slope, but the intercept is presumed to vary randomly about the population value in different species.
- A random slopes and intercepts model. A linear equation appears at level 1 relating lnPLD to lntemp. There is assumed to be a common population model about which individual species models vary. Individual species slope and intercepts values are assumed to deviate randomly about their population values.
- I write out the last model, the random slopes and intercepts model in detail below.

where
. The iid notation means independent and identically distributed and refers to the fact that error terms and random effects with different values of the subscript are independent but share a common distribution. In other words, the random variations within a species are independent (and independent of those from other species) and the random effects for a species are independent of the random effects from other species.
- A level-2 predictor is a variable that is measured on a level-2 unit and is constant for all measurements of that level-2 unit at level 1. For our example data set level-2 predictors are measured at the species level and are the same for that species on all of its measurement occasions. As an example, I show below the first 10 observations for selected variables in the larval development data set.
> inverts[1:10, c("species", "lnPLD", "lntemp", "climate.3", "feeding.type")]
species lnPLD lntemp climate.3 feeding.type
1 Amphiprion melanopus 2.509599 3.218876 tropical P
2 Amphiprion melanopus 2.197225 3.332205 tropical P
3 Armases miersii 2.960105 3.173878 tropical L
4 Armases miersii 2.397895 3.377588 tropical L
5 Balanus amphitrite 1 2.833213 2.708050 temperate P
6 Balanus amphitrite 1 2.639057 2.995732 temperate P
7 Balanus amphitrite 1 2.302585 3.135494 temperate P
8 Balanus amphitrite 1 2.079442 3.218876 temperate P
9 Balanus amphitrite 1 2.197225 3.295837 temperate P
10 Balanus eburneus 2.028148 2.995732 temperate P
- From the listing we see that lntemp is a level-1 predictor; it varies at each measurement occasion for each species.
- The variables climate.3 and feeding.type are level-2 predictors, they remain the same for a species at all of its level-1 observations. When the level-1 predictor is time or a variable that changes with time, the level-2 predictors are said to be time-invariant.
- Level-2 predictors are entered into a multilevel model at level 2. In our random slopes and intercepts example a level-2 predictor can be used to explain variability in species intercepts or in species slopes. Clearly since a level-2 predictor is measured on a species, it can only be used to explain differences between species, not differences that arise between measurement occasions for a single species.
- Let's consider a generic level-2 predictor that I'll denote z. Let the response be y and the level-1 predictor be x. Then we can enter z in the level-2 equation for the intercept, for the slope, or for both. I consider each possibility in turn.
Using a level-2 predictor to explain intercept variability
- Here the predictor z is entered into the equation for the intercept at level 2.

- Combining the level-1 and level-2 equations into a single composite model yields the following.

- The formulation shown in the last equation maps directly onto the way we would specify this model in R.
lme(fixed=y~1+x+z,random=~1+x|species,data=inverts)
or more simply because the intercept is assumed in each case.
lme(fixed=y~x+z,random=~x|species,data=inverts)
Using a level-2 predictor to explain slope variability
- Here the predictor z is entered into the equation for the slope at level 2.

- Combining the level-1 and level-2 equations into a single composite model yields the following.

- The formulation shown in the last equation maps directly onto the way we would specify this model in R.
lme(fixed=y~1+x+z:x,random=~1+x|species,data=inverts)
or more simply because the intercept is assumed in each case.
lme(fixed=y~x+z:x,random=~x|species,data=inverts)
Here the notation z:x is used to denote the interaction term in the model.
Using a level-2 predictor to explain slope and intercept variability
- In this scenario the predictor z is entered into the equations for both the intercept and slope at level 2.

- Combining the level-1 and level-2 equations into a single composite model yields the following.

- The formulation shown in the last equation maps directly onto the way we would specify this model in R.
lme(fixed=y~1+x+z+z:x,random=~1+x|species,data=inverts)
or more simply because the intercept is assumed present in each case.
lme(fixed=y~x+z+z:x,random=~x|species,data=inverts)
We can enter this even more simply using R's shortcut notation, x*z = x + z + x:z
lme(fixed=y~x*z,random=~x|species,data=inverts)
Some general comments
- Observe that when level-2 predictors are added they only affect the fixed effect portion of the model; the random effects portion remains unchanged. This will always be the case. The random effects are determined by the level-1 model. We can only declare parameters in the level-1 model to be random. If we don't add any parameters to the level-1 portion of the model, then the random effects component cannot change.
- The fixed effect portion of the model looks exactly like regression models we've considered in the past and in fact it is essentially the same. In the equations above the population mean value y is assumed to be a function of two predictors, x and z, in the various ways depicted in the models above. What's different is that we've also specified a second set of models at the species level. These arise because of the presence of the random effects.
- Thus a multilevel model consists of two models: a population-averaged (marginal) model and a subject-specific (conditional) model. The population-averaged model is one that just includes the fixed effects.
Population-averaged (marginal) model: 
The subject-specific model includes both the fixed and random effects (but not the level-1 error term).
Subject-specific (conditional) model: 
The notation used on the lefthand side of the last equation means that given values for the random effects, the mean of the response is as shown.
- One difference between these two models is that the subject-specific model is a derived model. It arises by starting with the population-averaged model and then tweaking the intercept (by adding u0i) and tweaking the slope (by adding u1i). The population-averaged model is the common theme in our data set. The subject-specific models are the (random) variations on that theme.
A concrete example using the climate variable in the larval development data set
- The climate variable records the geographic region in which a given species in the data set is predominantly found: polar, temperate, or tropics. It is a level-2 predictor because it describes a species, not a measurement occasion. It is a categorical variable and hence needs to be entered into a regression model as a set of dummy variables. The default dummy coding scheme selected by R is shown below.
> contrasts(inverts$climate.3)
temperate tropical
polar 0 0
temperate 1 0
tropical 0 1
- Let's denote the two dummy variables created by R as z1 and z2. If we assume that climate affects both the intercept and the slope of the development time/temperature relation in a random slopes and intercepts model, we are led to the following multilevel model.

or in composite form
- Because of the way the dummy variables are coded this corresponds to three population-averaged models and three sets of subject-specific models.
- Population-averaged models

- Subject-specific models (assuming the values of the random effects for the individual species are known)

- So instead of a single population model we now have three. The subject-specific models represent random deviations about the three population models. The polar species are assumed to have their own population equation about which they vary, the temperate species have their own population model about which they vary, and similarly for the tropical species.
- If the climate variable is a significant predictor in the multilevel model and explains a sizeable chunk of level-2 variance, or alternatively, if the AIC of a model that includes the climate variable is substantially lower than that of a model in which climate is omitted, then we can conclude that this triumvirate (three-pronged) way of viewing the data is "better" than thinking in terms of a single population model.
- It's worth keeping in mind that the random effects approach to analyzing structured data is an attempt to account for the structure with a minimal number of parameters.
- An alternative to the random coefficient model would be to model each species with a fixed effect just like we did in the birds-bats data set. With 74 species this would correspond to 73 dummy variables each with its own parameter in the intercept and slope equations. Thus using fixed effects would require the estimation of 146 additional parameters.
- In the random coefficients approach we don't actually estimate the random effects, instead we estimate the parameters of the distribution from which the random effects are supposed to arise. The distribution is a multivariate normal distribution described completely by three parameters,
,
, and
(because the mean is assumed to be zero). Thus we are attempting to do with three parameters that which the fixed effects approach would require 146 parameters to do.
- There is a philosophical difference between the two approaches too.
- The fixed effect approach focuses on the individual species while the random effects approach focuses on the underlying model.
- In the random effects approach the species are treated as being representative members of a population of similar species and not necessarily of interest in their own right. In the fixed effects approach we think of the current set of species as the only species of interest.
- One additional advantage of the random effects approach is that even species that do not provide enough data to allow estimation of their parameters in a fixed effects model (for example, species with fewer data values than parameter values), can contribute information in the random effects approach.
- We'll consider the problem of predicting individual random effects and assessing the assumptions of the random coefficient model next time.
Course Home Page