I am trying to run a linear mixed-effects model (package nlme) but I am repeatdly getting the Error: object of type 'closure' is not subsettable.

> 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

Thanks.

有帮助吗?

解决方案

The problem is that you are passing a function na.exclude() to the correlation argument of lme(). In effect your call is:

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

The code that handles the correlation argument makes certain assumptions, but it is certainly not expecting to be passed an irrelevant function.

You probably want to use the na.action argument, but you must name it if you don't supply the other arguments. You want

model.a <- lme(Timmrec ~ age, data = apoeht, random = ~ age | pathid, 
               na.action = na.exclude)
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top