在lmer模型上运行时,anova输出空白

时间:2013-03-01 07:17:04

标签: r anova lme4 lmer

我正在尝试使用lme4库运行anova模型。我没有任何实际数据,所以我只是从MASS中抽出Cars93数据。虽然我可以让lmer(...)工作,但我似乎无法将anova表打印出来。

以下是发生的事情:

> library(MASS)

> cars <- Cars93

> library(lme4)
Loading required package: Matrix
Loading required package: lattice

Attaching package: ‘lme4’

The following object(s) are masked from ‘package:stats’:

AIC, BIC

> fit <- lmer(Max.Price ~ 1+(1|AirBags)+(1|Man.trans.avail), data=cars)
> anova(fit)
Analysis of Variance Table
Df Sum Sq Mean Sq F value   
> summary(fit)
Linear mixed model fit by REML 
Formula: Max.Price ~ 1 + (1 | AirBags) + (1 | Man.trans.avail) 
Data: cars 
AIC   BIC logLik deviance REMLdev
688 698.1   -340    685.1     680
Random effects:
Groups          Name        Variance Std.Dev.
AirBags         (Intercept) 62.2339  7.8888  
Man.trans.avail (Intercept)  6.3022  2.5104  
Residual                    83.2786  9.1257  
Number of obs: 93, groups: AirBags, 3; Man.trans.avail, 2

Fixed effects:
            Estimate Std. Error t value
(Intercept)    23.81       5.00   4.761

非常感谢任何帮助或建议。

1 个答案:

答案 0 :(得分:1)

我认为你的公式中需要一个变量才能使用anova。例如

fit <- lmer(Max.Price ~ Weight + (1 | AirBags) + (1 | Man.trans.avail),data=cars)

anova(fit)
Analysis of Variance Table
       Df Sum Sq Mean Sq F value
Weight  1 1932.1  1932.1   29.67