質問

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