Question

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.

Was it helpful?

Solution

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)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top