# Split-plot 1: How does a linear mixed model look like?

I like statistics and I struggle with statistics. Often times I get frustrated when I don’t understand and I really struggled to make sense of Krushke’s Bayesian analysis of a split-plot, particularly because ‘it didn’t look like’ a split-plot to me.

Additionally, I have made a few posts discussing linear mixed models using several different packages to fit them. At no point I have shown what are the calculations behind the scenes. So, I decided to combine my frustration and an explanation to myself in a couple of posts. This is number one and the follow up is Split-plot 2: let’s throw in some spatial effects. Example of forestry split-plot: one of my colleagues has a trial in which stocking (number of trees per ha) is the main plot and fertilization is the subplot (higher stockings look darker because trees are closer together).

## How do linear mixed models look like

Linear mixed models, models that combine so-called fixed and random effects, are often represented using matrix notation as:

$$oldsymbol{y} = oldsymbol{X b} + oldsymbol{Z a} + oldsymbol{e}$$

where $$oldsymbol{y}$$ represents the response variable vector, $$oldsymbol{X} mbox{ and } oldsymbol{Z}$$ are incidence matrices relating the response to the fixed ($$oldsymbol{b}$$ e.g. overall mean, treatment effects, etc) and random ($$oldsymbol{a}$$, e.g. family effects, additive genetic effects and a host of experimental design effects like blocks, rows, columns, plots, etc), and last the random residuals ($$oldsymbol{e}$$).

The previous model equation still requires some assumptions about the distribution of the random effects. A very common set of assumptions is to say that the residuals are iid (identical and independently distributed) normal (so $$oldsymbol{R} = sigma^2_e oldsymbol{I}$$) and that the random effects are independent of each other, so $$oldsymbol{G} = oldsymbol{B} igoplus oldsymbol{M}$$ is a direct sum of the variance of blocks ($$oldsymbol{B} = sigma^2_B oldsymbol{I}$$) and main plots ($$oldsymbol{M} = sigma^2_M oldsymbol{I}$$).

An interesting feature of this matrix formulation is that we can express all sort of models by choosing different assumptions for our covariance matrices (using different covariance structures). Do you have longitudinal data (units assessed repeated times)? Is there spatial correlation? Account for this in the $$oldsymbol{R}$$ matrix. Random effects are correlated (e.g. maternal and additive genetic effects in genetics)? Account for this in the $$oldsymbol{G}$$ matrix. Multivariate response? Deal with unstructured $$oldsymbol{R}$$ and $$oldsymbol{G}$$, or model the correlation structure using different constraints (and the you’ll need asreml).

By the way, the history of linear mixed models is strongly related to applications of quantitative genetics for the prediction of breeding values, particularly in dairy cattle. Charles Henderson developed what is now called Henderson’s Mixed Model Equations to simultaneously estimate fixed effects and predict random genetic effects:

$$left [ egin{array}{cc} oldsymbol{X}’ oldsymbol{R}^{-1} oldsymbol{X} & oldsymbol{X}’ oldsymbol{R}^{-1} oldsymbol{Z} \ oldsymbol{Z}’ oldsymbol{R}^{-1} oldsymbol{X} & oldsymbol{Z}’ oldsymbol{R}^{-1} oldsymbol{Z} + oldsymbol{G}^{-1} end{array} ight ] left [ egin{array}{c} oldsymbol{b} \ oldsymbol{a} end{array} ight ] = left [ egin{array}{c} oldsymbol{X}’ oldsymbol{R}^{-1} oldsymbol{y} \ oldsymbol{Z}’ oldsymbol{R}^{-1} oldsymbol{y} end{array} ight ]$$

The big matrix on the left-hand side of this equation is often called the $$oldsymbol{C}$$ matrix. You could be thinking ‘What does this all mean?’ It is easier to see what is going on with a small example, but rather than starting with, say, a complete block design, we’ll go for a split-plot to start tackling my annoyance with the aforementioned blog post.

## Old school: physical split-plots

Given that I’m an unsophisticated forester and that I’d like to use data available to anyone, I’ll rely on an agricultural example (so plots are actually physical plots in the field) that goes back to Frank Yates. There are two factors (oats variety, with three levels, and fertilization, with four levels). Yates, F. (1935) Complex experiments, Journal of the Royal Statistical Society Suppl. 2, 181–247 (behind pay wall here). Layout of oats experiment in Yates’s paper, from a time when articles were meaty. Each of the 6 replicates is divided in to 3 main plots for oats varieties (v1, v2 and v3), while each variety was divided into four parts with different levels of fertilization (manure—animal crap—n1 to n4). Cells display yield.

Now it is time to roll up our sleeves and use some code, getting the data and fitting the same model using nlme (m1) and asreml (m2), just for the fun of it. Anyway, nlme and asreml produce exactly the same results.

We will use the oats data set that comes with MASS, although there is also an Oats data set in nlme and another version in the asreml package. (By the way, you can see a very good explanation by Bill Venables of a ‘traditional’ ANOVA analysis for a split-plot here):

Now we can move to implement the Mixed Model Equations, where probably the only gotcha is the definition of the $$oldsymbol{Z}$$ matrix (incidence matrix for random effects), as both nlme and asreml use ‘number of levels of the factor’ for both the main and interactions effects, which involves using the contrasts.arg argument in model.matrix().

Not surprisingly, we get the same results, except that we start assuming the variance components from the previous analyses, so we can avoid implementing the code for restricted maximum likelihood estimation as well. By the way, given that $$oldsymbol{R}^{-1}$$ is in all terms it can be factored out from the MME, leaving terms like $$oldsymbol{X}’ oldsymbol{X}$$, i.e. without $$oldsymbol{R}^{-1}$$, making for simpler calculations. In fact, if you drop the $$oldsymbol{R}^{-1}$$ it is easier to see what is going on in the different components of the $$oldsymbol{C}$$ matrix. For example, print $$oldsymbol{X}’ oldsymbol{X}$$ and you’ll get the sum of observations for the overall mean and for each of the levels of the fixed effect factors. Give it a try with the other submatrices too!

I will leave it here and come back to this problem as soon as I can.

† Incidentally, a lot of the theoretical development was supported by Shayle Searle (a Kiwi statistician and Henderson’s colleague in Cornell University). Avi says:

Thanks! Now for some plots please 🙂 Kevin Wright says:

You can also find this dataset in my package:
require(“agridat”)
?yates.oats

I included the field coordinates and discovered that there was a strong gradient across the field, which makes the modeling process more interesting if you want to include a linear term to model the spatial trend. Some plots are included. Luis says:

Hi Kevin,

I’m preparing part 2 of this post—as an exercise in procrastination while marking exams—where I do mention agridat. Stay tuned. John K. Kruschke says:

Hi Luis. I agree that it can be annoying when terminology doesn’t seem to match across fields. Brings furrows to the brow.

When you commented on my post, suggesting I use the “oats” data from R, I couldn’t understand what made those data a split-plot design like what Maxwell & Delaney were calling a split-plot design, as I said in my reply comment http://doingbayesiandataanalysis.blogspot.com/2012/05/split-plot-design-in-jags-revised.html?showComment=1338386264700#c9133242812476294179 .

Here’s my understanding of how Maxwell & Delaney use the term “split plot design” when applied to between-subject and within-subject factors in psychological experiments. What corresponds to a “whole plot” is a subject (i.e., person) in an experiment. Each whole-plot person gets only one level of the “between-subject” factor A. But each person gets all levels of the “within-subject” factor B. The levels of the within-subject factor are administered in a random order through time, so those different positions in time are the “split plots” or “sub plots”.

If I understand the oats data correctly, in psychology terminology they are from a two-factor, completely within-subject design. For each whole plot (person), every combination of both factors was administered, albeit in different random arrangements, which would be like different random orders through time for people in the experiment. Thus, as I tried to indicate in my comment linked above, the oats data don’t have the same structure as the “split plot” example from Maxwell & Delaney. Luis says:

Hi John,

Thanks for the comment. In the second part of this post I’ll, eventually, go for an MCMC analysis of oats and see where I end up. Nomenclature differences across disciplines are confusing (to say it politely), which combined with moving from REML to MCMC made the whole exercise puzzling. With some luck we’ll end up on the same page. moneyandfinanceinformation says:

How do you extract the means of the fixed effects from the mixed model?