[R] 2 lme questions

Spencer Graves spencer.graves at pdf.com
Tue Apr 6 00:54:38 CEST 2004


      The "print" method and the "summary" command display the STANDARD 
DEVIATIONS (not the variances) on the screen (or in a sink file).  
However, when I do attributes(lme(...)) and 
attributes(summary(lme(...))), I don't see anything I can use.  
Fortunately, the "interval" function produces a list, from which the 
variance estimates can be extracted.  Consider the following example: 

DF <- data.frame(group=c(1,1,2,2), y=c(1, 2, 11, 12))
library(nlme)
fit <- lme(y~1, random=~1|group, DF)

Linear mixed-effects model fit by REML
  Data: DF
  Log-restricted-likelihood: -6.559401
  Fixed: y ~ 1
(Intercept)
        6.5

Random effects:
 Formula: ~1 | group
        (Intercept)  Residual
StdDev:    7.053597 0.7070954

Number of Observations: 4
Number of Groups: 2
 > lme.int <- intervals(fit)
 > lme.int$reStruct^2
Error in lme.int$reStruct^2 : non-numeric argument to binary operator

 > lme.int$reStruct$group^2
                  lower     est.    upper
sd((Intercept)) 3.06859 49.75323 806.6845
 > lme.int$sigma^2
    lower      est.     upper
0.0704255 0.4999839 3.5496217
attr(,"label")
[1] "Within-group standard error:"

      There may be a better way;  if there is, I hope someone will 
enlighten us all.  If not, at least this works in R 1.8.1

      hope this helps.  spencer graves


Harold Doran wrote:

>There are two way to accomplish this in nlme. First try using the summary() command, which will produce all variance components and estimates for the fixed effects. Also, try the following to extract the point estimates and approximate CIs for the variance comonents.
>
>  
>
>>intervals(model.lme, which="var")
>>    
>>
>
>Harold
>
>-----Original Message-----
>From: r-help-bounces at stat.math.ethz.ch
>[mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of Steve Roberts
>Sent: Monday, April 05, 2004 3:32 PM
>To: r-help at stat.math.ethz.ch
>Cc: Steve Roberts
>Subject: [R] 2 lme questions
>
>
>Greetings,
>
>1) Is there a nice way of extracting the variance estimates from an lme fit? They don't seem to be part of the lme object.
>
>2) In a series of simulations, I am finding that with ML fitting one of my random effect variances is sometimes being estimated as essentially zero with massive CI instead of the finite value it should have, whilst using REML I get the expected value. I guess it is a numerical/optimisation problem but don't know enough about the lme fitting algorithm to know which tollerance/scale parameter to mess about with. Any suggestions where to start? 
>
>Thanks,
>
>Steve.
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>  
>




More information about the R-help mailing list