刚刚在我的 Windows 7 机器上安装了 R 版本 3.0.1 以使用 package nlme,我发现lme()
package 中的函数所适合的模型存在巨大差异lme4
。请注意,这些结果的不同还在于 R 2.15.2 使用 lme4 1.0-4,而 R 3.0.1 使用 lme4 1.1-6(均使用 安装install.packages("lme4")
)。
许多值相差一个数量级(REML 标准、随机效应,最明显的是 ANOVA p 值)。
我认为这是一个(主要)错误,但我想先咨询社区。此外,如果更合适,请随时将此问题迁移到 CrossValidated。
下面是一个简单设计的输出。
使用 R 2.15.2
version$major
## [1] "2"
version$minor
## [1] "15.2"
library(lme4)
## Warning: package 'lme4' was built under R version 2.15.3
## Loading required package: lattice
## Warning: package 'lattice' was built under R version 2.15.3
## Loading required package: Matrix
## Warning: package 'Matrix' was built under R version 2.15.3
sessionInfo()$otherPkgs$lme4$Version
## [1] "1.0-4"
data = read.csv("correct_data.csv")
null_model = lmer(dv ~ (1 | subject) + (1 | target), data = data)
alt_model = lmer(dv ~ condition + (1 | subject) + (1 | target), data = data)
summary(alt_model)
## Linear mixed model fit by REML ['lmerMod']
## Formula: dv ~ condition + (1 | subject) + (1 | target)
## Data: data
##
## REML criterion at convergence: 486.9
##
## Random effects:
## Groups Name Variance Std.Dev.
## subject (Intercept) 0.00299 0.0547
## target (Intercept) 0.00217 0.0465
## Residual 0.17733 0.4211
## Number of obs: 423, groups: subject, 38; target, 7
##
## Fixed effects:
## Estimate Std. Error t value
## (Intercept) 0.1185 0.0336 3.52
## condition 0.0983 0.0414 2.37
##
## Correlation of Fixed Effects:
## (Intr)
## condition -0.532
anova(null_model, alt_model)
## Data: data
## Models:
## null_model: dv ~ (1 | subject) + (1 | target)
## alt_model: dv ~ condition + (1 | subject) + (1 | target)
## Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq)
## null_model 4 491 507 -241 483
## alt_model 5 487 507 -238 477 5.55 1 0.018 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
使用 R 3.0.1
version$major
## [1] "3"
version$minor
## [1] "1.0"
library(lme4)
## Loading required package: Matrix
## Loading required package: Rcpp
sessionInfo()$otherPkgs$lme4$Version
## [1] "1.1-6"
data = read.csv("correct_data.csv")
null_model = lmer(dv ~ (1 | subject) + (1 | target), data = data)
alt_model = lmer(dv ~ condition + (1 | subject) + (1 | target), data = data)
summary(alt_model)
## Linear mixed model fit by REML ['lmerMod']
## Formula: dv ~ condition + (1 | subject) + (1 | target)
## Data: data
##
## REML criterion at convergence: 5242
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.9112 -0.8148 0.0376 0.8111 1.9040
##
## Random effects:
## Groups Name Variance Std.Dev.
## subject (Intercept) 760 27.6
## target (Intercept) 122 11.0
## Residual 13911 117.9
## Number of obs: 423, groups: subject, 38; target, 7
##
## Fixed effects:
## Estimate Std. Error t value
## (Intercept) 204.3 9.8 20.86
## condition 17.8 11.6 1.53
##
## Correlation of Fixed Effects:
## (Intr)
## condition -0.509
anova(null_model, alt_model)
## refitting model(s) with ML (instead of REML)
## Data: data
## Models:
## null_model: dv ~ (1 | subject) + (1 | target)
## alt_model: dv ~ condition + (1 | subject) + (1 | target)
## Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq)
## null_model 4 5265 5281 -2629 5257
## alt_model 5 5265 5285 -2627 5255 2.33 1 0.13