We have run some mixed models in a paper where we replicated all SPSS-results in R. This was our syntax:
MIXED y BY x1 WITH x2 x3
/CRITERIA=CIN(95) MXITER(100) MXSTEP(10) SCORING(1) SINGULAR(0.000000000001) HCONVERGE(0,
ABSOLUTE) LCONVERGE(0, ABSOLUTE) PCONVERGE(0.000001, ABSOLUTE)
/FIXED=x1 x2 x3 | SSTYPE(3)
/METHOD=REML
/PRINT=G R SOLUTION TESTCOV
/RANDOM=INTERCEPT x1 | SUBJECT(id) COVTYPE(UN)
/REPEATED=x1| SUBJECT(id) COVTYPE(UN).
lmer(
y ~ x1 + x2 + x3 + (1 + x1 | id),
data = data,
# this one is required because the random slope
# is categorical. else, you could model uncorrelated
# slope / intercept, see below
control = lmerControl(check.nobs.vs.nRE = "ignore")
)
or
lmer(
y ~ x1 + x2 + x3 + (1 + x1 || id),
data = data
)
We have converted our time-variable x1
to a factor, because it seemed like SPSS cannot deal with numeric time-variables in the REPEATED
-statement.
To get the same standard errors, p-values and confidence intervals, use lmerTest::summary(..., ddf = "Satterthwaite")
, because SPSS uses Satterthwaite-approximation as default.