[R-sig-ME] how to extract the values in the nlme package?
Douglas Bates
bates at stat.wisc.edu
Tue Oct 7 23:12:51 CEST 2008
On Tue, Oct 7, 2008 at 2:06 AM, Ming Liu <dannyliu1002 at yahoo.com.cn> wrote:
> Dear friends,
>
> I take a lm for an example.
>>
>> Call:
>> lm(formula = weight ~ group)
>> Residuals:
>> Min 1Q Median 3Q Max
>> -1.0710 -0.4938 0.0685 0.2462 1.3690
>> Coefficients:
>> Estimate Std. Error t value Pr(>|t|)
>> (Intercept) 5.0320 0.2202 22.850 9.55e-15 ***
>> groupTrt -0.3710 0.3114 -1.191 0.249
>> ---
>> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
>> Residual standard error: 0.6964 on 18 degrees of freedom
>> Multiple R-squared: 0.07308, Adjusted R-squared: 0.02158
>> F-statistic: 1.419 on 1 and 18 DF, p-value: 0.249
> I can use the commands (summary(lm.D9)$r.squared,
> summary(lm.D9)$coef[1,4]) to extract the values(r.squared, p-value)
> from the above result.
But that only works if there are components named r.squared and coef
in the object returned by the summary method and it really has nothing
to do with the object returned by an nlme or lme fit. If you want the
estimate of the standard deviation of the random effects, you should
look at
> library(nlme)
> ?VarCorr
> example(VarCorr)
VarCrr> fm1 <- lme(distance ~ age, data = Orthodont, random = ~age)
VarCrr> VarCorr(fm1)
Subject = pdLogChol(age)
Variance StdDev Corr
(Intercept) 5.41508751 2.3270341 (Intr)
age 0.05126955 0.2264278 -0.609
Residual 1.71620400 1.3100397
It happens that the object returned by VarCorr is a character matrix
(not a really great design, I must admit) so you would need to use
something like
as.numeric(VarCorr(fm1)["(Intercept)", "StdDev"])
to get the numeric value.
> So, in your package I want to extract the values the StdDev of Random
> effects, could you give me a hand ? Thank you so much indeed.
>
>
>
> Best wishes,
>
> Danny
>
>
>
> ---------------------------------
> 雅虎邮箱，您的终生邮箱！
> [[alternative HTML version deleted]]
>
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
>
More information about the R-sig-mixed-models
mailing list