2014-01-17 539 views
0

我想运行线性混合效果模型(包nlme),但我重复得到错误:类型'closure'的对象不是子集。lme - 错误:类型'closure'的对象不是子集合

> apoeht <- read.csv("apoeht.csv") 
> library(nlme) 
> model.a <- lme(Timmrec ~ age, data = apoeht, random = ~ age | pathid, 
+    na.exclude) 
Error: object of type 'closure' is not subsettable 

谢谢。

+2

你正在传递'na.exclude'作为第四个参数,它是'correlation'。相反,在那里使用命名的参数:'na.action = na.exclude' – Justin

+0

这个问题已经在这个论坛上讨论过[这里(“http://stackoverflow.com/questions/11308367/object-of-type-closure-是 - 不subsettable“)] – heybhai

回答

3

问题是,您正在将函数na.exclude()传递给lme()的参数correlation。实际上你的电话是:

model.a <- lme(Timmrec ~ age, data = apoeht, random = ~ age | pathid, 
       correlation = na.exclude) 

处理该correlation参数进行一些假设的代码,但它肯定是不希望传递一个不相关的功能。

您可能想要使用na.action参数,但如果您不提供其他参数,则必须命名该参数。你想要

model.a <- lme(Timmrec ~ age, data = apoeht, random = ~ age | pathid, 
       na.action = na.exclude) 
相关问题