Random Effects

This week we further explored random effects in mixed models.

There are two main types of random effects that we investigated this week: nested and crossed random effects

First, I’ll review nested random effects.

Nested

From my limited understanding, you get nested random effects when your data is nested in some way.

We discussed an example with schools, teachers, and studentsin class, so I will use that for this section.

The reason this data is school data set is nested is because certain teachers exclusively belong to certain schools. And certain students belong to specific teachers.

The school example is a great example because it has a natural progression to the data and if we are evaluating test scores it is clear that there would be correlations in the scores among students in the same school and within individual classrooms.

To denote nested random effects in a model I believe you do the following:

response ~ (1|group1/group2)

where group 2 is nested within group 1

Crossed

Crossed random effects can essentially be attributed to random effects when the data is not nested. For example, imagine a handful of factories producing a variety of different parts and we want to evaluate the quality of production. Factory A, Factory B, and Factory C can all make Part 1, Part 2, and Part 3.

Just visually thinking about this data, we can imagine three lines coming from Factory A to the 3 different parts with the same being true for the other two factories.

The lines crisscross all over the place which leads me to conclude the data is indeed not nested.

This means we need crossed random effects.

To denote crossed random effects in a model you type this into the model code:

response ~ (1|group1) + (1 |group2)

Summary

It gets a little confusing to think of these two random effect types as completely separate kinds of random effects. It helps me to think of Crossed random effects as belonging to data sets that are not nested. If the data is naturally nested then nested random effects are obviously the choice.

If I am ever confused at which kind I am dealing with, it is easy enough to grab a piece of scratch paper and draw out the different relationships. If there is a nice, flowing progression of the data I know it is nested and if there is a confusing spiderweb of lines I know my random effects need to be crossed.