direction = both
我正在尝试使用 MASS 包中的 stepAIC 在 R 中使用 stepAIC 模型选择来找到基于 AIC 的最佳模型。
这是我使用的脚本:
stepAIC (glmer(decision ~ as.factor(Age) + as.factor(Educ) + as.factor(Child), family=binomial, data=RShifting), direction="both")
但是我得到了这个错误结果:
Error in lmerFactorList(formula, fr, 0L, 0L) :
No random effects terms specified in formula
我试图添加(1|town)
到公式中,因为城镇是随机效应(受访者嵌套的地方)并运行了这个脚本):
stepAIC (glmer(decision ~ as.factor(Age) + as.factor(Educ) + as.factor(Child) + (1|town), family=binomial, data=RShifting), direction="both")
结果是这样的:
Error in x$terms : $ operator not defined for this S4 class
我希望你能帮助我弄清楚如何解决这个问题。非常感谢。