# Two Ways of Specifying Random Intercepts in SPSS’s Mixed Model

To do: Screenshots of SPSS dialogues.

In SPSS’s Mixed Models dialogue, there are two ways to enter random intercepts, either by the Subjects and Repeated measures dialogue (the first window upon opening the dialogue) or the Random subdialogue. This document shows how to generate identical results using either option.

## Loading data in R

We’ll use R to get the data, demostrate the model we’re trying to fit, and export the data for SPSS. The data comes from Brady West.

library("tidyverse") ratpup <- readr::read_delim("http://www-personal.umich.edu/~bwest/rat_pup.dat", "\t")

Make the treatment binary, and convert both it and sex to numeric.

ratpup <- ratpup %>% mutate(treat = (treatment != "Control") + 0) %>% mutate(female = (sex == "Female") + 0) %>% select(-c(treatment, sex)) %>% as.data.frame()

Write the data into SPSS

library("foreign") write.foreign(ratpup, datafile = "ratpup.sav", codefile = "ratpup.sps", package = "SPSS")

The mixed model we’ll be fitting has a random intercept per litter:

## SPSS

Open the file `ratpup.sps`

and run the code to load the data.

We’ll run two variations using the dialogue Analyze -> Mixed Models -> Linear.

First, ignore the first screen. Place `weight`

in Dependent
variable; `treat`

, `female`

and `litter`

into Factors, and `litsize`

into
Covariates. In the Fixed subdialogue, enter the main effect for litsize
and the main and interaction of `treat`

and `female`

. In the Random subdialogue,
place `litter`

into the Model. Do **not** check
the box “Include intercept”.

This dialogue should produce the following syntax:

```
MIXED weight BY female litter treat WITH litsize
/CRITERIA=CIN(95) MXITER(100) MXSTEP(10) SCORING(1) SINGULAR(0.000000000001)
HCONVERGE(0, ABSOLUTE) LCONVERGE(0, ABSOLUTE) PCONVERGE(0.000001, ABSOLUTE)
/FIXED=female treat female*treat litsize | SSTYPE(3)
/METHOD=REML
/PRINT=SOLUTION
/RANDOM=litter | COVTYPE(VC).
```

In this model, `litter`

was chosen as “subject” in the first
screen. Random Intercept was included but not `litter`

, and
`litter`

was included in “Subject groupings”

Next, we’ll make use of the first screen. In the first screen, place
`little`

into Subjects. Enter the variables as described
above. `litter`

does not have to be placed in Factors
anymore, but it will not affect anything if it is. In the Random
subdialogue, check “Include intercept”. Do **not**
enter `litter`

into Model, but at the bottom under Subject
Groups, enter it into Combinations.

The syntax is:

```
MIXED weight BY female treat WITH litsize
/CRITERIA=CIN(95) MXITER(100) MXSTEP(10) SCORING(1) SINGULAR(0.000000000001)
HCONVERGE(0, ABSOLUTE) LCONVERGE(0, ABSOLUTE) PCONVERGE(0.000001, ABSOLUTE)
/FIXED=female treat female*treat litsize | SSTYPE(3)
/METHOD=REML
/PRINT=SOLUTION
/RANDOM=INTERCEPT | SUBJECT(litter) COVTYPE(VC).
```

The difference is highlighted in red; specifically

/RANDOM=litter | COVTYPE(VC).

versus

/RANDOM=INTERCEPT | SUBJECT(litter) COVTYPE(VC).

but both models are identical.