简体   繁体   English

SPSS的MIXED过程中的REPEATED子命令的lmer / nlme等效项是什么?

[英]What is the lmer/nlme equivalent of the REPEATED subcommand in SPSS's MIXED procedure?

I came across an SPSS syntax like this 我遇到了像这样的SPSS语法

MIXED value BY factor1
    /CRITERIA=CIN(95) MXITER(100) MXSTEP(10) SCORING(1) SINGULAR(0.000000000001)
    HCONVERGE(0, ABSOLUTE) LCONVERGE(0, ABSOLUTE) PCONVERGE(0.000001,
    ABSOLUTE)
    /FIXED=factor1 | SSTYPE(3)
    /METHOD=REML
    /REPEATED=factor1 | SUBJECT(participant) COVTYPE(UN).

and struggle to find an equivalent lmer / nlme (or R in general) formulation for this kind of models. 并努力为这种模型找到等效的lmer / nlme (或通常为R)公式。

Does anybody know how to convert the REPEATED subcommand into R code? 有人知道如何将REPEATED子命令转换为R代码吗?

This summarizes the answers I got on the r-sig-mixed-models mailing list: 这总结了我在r-sig-mixed-models邮件列表中得到的答案
The REPEATED command specifies the structure in the residual variance-covariance matrix ( R matrix), the so-called R-side structure, of the model . REPEATED命令指定在剩余方差-协方差矩阵(R矩阵)的结构中,所谓的R侧的结构,的模型 For lme4::lmer() this structure is fixed to a multiple of the identity matrix. 对于lme4::lmer()此结构固定为单位矩阵的倍数。 However, one can specify the R-side structure using the weights and correlation arguments in nlme::gls() as follows: 但是,可以使用nlme::gls()weightscorrelation参数来指定R端结构,如下所示:

gls(value ~ factor1,
    correlation = corSymm(form = ~ 1|participant),
    weights = varIdent(form = ~1|factor1),
    method = "REML", 
    data = data)

If one needs G-side effects in addition to the R-side structure, nlme::lme() provides the appropriate extensions. 如果除了R侧结构之外还需要G侧效果,则nlme::lme()提供适当的扩展。

We have run some mixed models in a paper where we replicated all SPSS-results in R. This was our syntax: 我们已经在论文中运行了一些混合模型,并在其中复制了R中的所有SPSS结果。这是我们的语法:

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. 我们将时间变量x1转换为一个因子,因为SPSS似乎无法在REPEATED语句中处理数字时间变量。

To get the same standard errors, p-values and confidence intervals, use lmerTest::summary(..., ddf = "Satterthwaite") , because SPSS uses Satterthwaite-approximation as default. 要获得相同的标准误差,p值和置信区间,请使用lmerTest::summary(..., ddf = "Satterthwaite") ,因为SPSS默认使用Satterthwaite-approximation。

I believe that /REPEATED is just the way to specify random effects, so 我相信/REPEATED只是指定随机效果的方式,因此

random=~factor1|participant in nlme. nlme中的random=~factor1|participant

I'm also guessing that the intercept in both the fixed and the random effects is implicit. 我还猜测固定和随机效应中的截距都是隐式的。

So in lme4 + lmerTest the whole model might be: 因此,在lme4 + lmerTest中,整个模型可能是:

m <- lmerTest::lmer(value ~ 1 + factor1 + (1+factor1|participant))
lmerTest::anova(m, type=3,ddf='Satterthwaite')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM