lme - Error: object of type 'closure' is not subsettable [duplicate]

StackOverflow https://stackoverflow.com/questions/21176856

  •  29-09-2022
  •  | 
  •  

سؤال

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