本文介绍了在lmer输出上运行汽车Anova后列表类型错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在R中创建随机效果模型.我想在输出中运行 anova ,我浏览了一些教程并复制了示例,但我的不是在职的.我在Anova上不断收到以下错误消息:

I'm trying to do a random effects model in R. I want to run an anova on the output, I've looked through a few tutorials and copied their examples but mine isn't working. I keep getting the following error on the Anova:

我正在运行的代码在下面,对于任何人对问题有什么想法,将不胜感激!

The code I'm running is below, any ideas anyone has on what the problem is would be most appreciated!

library(lme4)
library(car)

div1<-rep(1,5)
div2<-rep(2,3)
div3<-rep(3,3)
div6<-rep(6,6)
div<-c(div1,div2,div3,div6)
res<-c(3.8082479,7.7819745,3.3792467,7.2288647,3.4564646,1.8043898,5.1443293,3.9467614,2.5922306,1.9996585,4.2004104,0.7290807,2.1854365,3.4118980,3.2464388,2.9607496,1.9993038)
df<-data.frame(div,res)

randeff<-lmer(res~1+(1|div),data=df,REML=FALSE)
summary(randeff)
Anova(randeff)

推荐答案

car :: Anova 仅用于分析固定效果.您试图分析一个没有随机影响的模型,因此感到不满意(不幸的是,错误消息难以理解).要检验此假设,请在数据集中添加一个随机列,然后在模型中添加固定的效果:

car::Anova is designed for analyzing fixed effects only. You tried to analyze a model with no random effects, so it got unhappy (unfortunately, the error message was inscrutable). To test this hypothesis, add a random column to your data set and a fixed effect to the model:

> df$y <- rnorm(nrow(df))
> randeff2 <- lmer(res~y+(1|div),data=df,REML=FALSE)
> Anova(randeff2)
Analysis of Deviance Table (Type II Wald chisquare tests)

Response: res
   Chisq Df Pr(>Chisq)
y 0.0418  1      0.838

这篇关于在lmer输出上运行汽车Anova后列表类型错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-09 23:46