Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extracting confidence intervals from lme model

I have to make some transformations on the confidence intervals of multiple large models made with the lme() function from the nlme package. I'm using the intervals() function to get the intervals, however it is not possible to turn it into a dataframe. Is there any way I could turn this into accessable numbers?

library(nlme)
data(mtcars)
model = lme(mpg ~ disp + cyl, random=~1|gear,  data=mtcars)
CI<-intervals(model, which = "fixed")
Approximate 95% confidence intervals

 Fixed effects:
              lower        est.         upper
(Intercept) 29.43497446 34.66099475 39.8870150353
disp        -0.04163023 -0.02058363  0.0004629675
cyl         -3.04786061 -1.58727681 -0.1266930105
attr(,"label")
[1] "Fixed effects:"

data.frame(CI)
Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = 
stringsAsFactors) : 
  cannot coerce class ‘"intervals.lme"’ to a data.frame
like image 229
Fanni Daniella Szakál Avatar asked Oct 17 '25 14:10

Fanni Daniella Szakál


1 Answers

You can use CI$fixed to get the values, then storing in a data frame. E.g.

df <- data.frame(CI$fixed)
like image 200
CIAndrews Avatar answered Oct 20 '25 03:10

CIAndrews