Galadude
Galadude

Reputation: 253

Extract range of NLME object

I have a NLME object with a correlation. I was wondering how I could extract the range of the correlation from the model. I'm running simulations, so I can't just read the summary, and get it manually.

So my model looks something like this:

library(MASS)
library(nlme)
lme(fixed=temp ~ time, random=~1|day,correlation=corExp(form=~time),data=beav1)

So I'd like to get the parameter of the correlation here.

Upvotes: 3

Views: 542

Answers (1)

Gregor Thomas
Gregor Thomas

Reputation: 145775

That took a lot of digging to find! I had to look at the code for nlme:::print.summary.lme to find $modelStruct$corStruct, and then at nlme:::print.summary.corStruct to get there.

This should work

library(datasets)
library(nlme)
mod <- lme(fixed = temp ~ time, random = ~1|day,
           correlation = corExp(form=~time), data=beaver1)

store_range <- coef(mod$modelStruct$corStruct, unconstrained = F)

Yielding

> store_range
   range 
58.82908 

Upvotes: 4

Related Questions