[R] Extracting Variance components
I can ask my question using and example from Chapter 1 of Pinheiro Bates. # 1.4 An Analysis of Covariance Model OrthoFem - Orthodont[ Orthodont$Sex == Female, ] fm1OrthF - + lme( distance ~ age, data = OrthoFem, random = ~ 1 | Subject ) summary( fm1OrthF ) Linear mixed-effects model fit by REML Data: OrthoFem AIC BIClogLik 149.2183 156.169 -70.60916 Random effects: Formula: ~1 | Subject (Intercept) Residual StdDev: 2.06847 0.7800331 [...etc...] I can extract the estimate of the variance component \sigma (0.7800331) via sigma - fm1OrthF$sigma How do I extract the other component \sigma_b (2.06847) ? Cheers, Murray Jorgensen -- Dr Murray Jorgensen http://www.stats.waikato.ac.nz/Staff/maj.html Department of Statistics, University of Waikato, Hamilton, New Zealand Email: [EMAIL PROTECTED]Fax 7 838 4155 Phone +64 7 838 4773 wkHome +64 7 825 0441Mobile 021 1395 862 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Extracting Variance components
Murray, you'll find it in VarCorr(fm1OrthF) Cheers Andrew On Mon, Jun 05, 2006 at 04:29:48PM +1200, Murray Jorgensen wrote: I can ask my question using and example from Chapter 1 of Pinheiro Bates. # 1.4 An Analysis of Covariance Model OrthoFem - Orthodont[ Orthodont$Sex == Female, ] fm1OrthF - + lme( distance ~ age, data = OrthoFem, random = ~ 1 | Subject ) summary( fm1OrthF ) Linear mixed-effects model fit by REML Data: OrthoFem AIC BIClogLik 149.2183 156.169 -70.60916 Random effects: Formula: ~1 | Subject (Intercept) Residual StdDev: 2.06847 0.7800331 [...etc...] I can extract the estimate of the variance component \sigma (0.7800331) via sigma - fm1OrthF$sigma How do I extract the other component \sigma_b (2.06847) ? Cheers, Murray Jorgensen -- Dr Murray Jorgensen http://www.stats.waikato.ac.nz/Staff/maj.html Department of Statistics, University of Waikato, Hamilton, New Zealand Email: [EMAIL PROTECTED]Fax 7 838 4155 Phone +64 7 838 4773 wkHome +64 7 825 0441Mobile 021 1395 862 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Andrew Robinson Department of Mathematics and StatisticsTel: +61-3-8344-9763 University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599 Email: [EMAIL PROTECTED] http://www.ms.unimelb.edu.au __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Extracting variance components from lmer
On 2/21/06, Christoph Buser [EMAIL PROTECTED] wrote: Hi Rick There may be a better way, but the following should work: attributes(vc.fit)$sc That works but a more direct way would be attr(vc.fit, sc) By the way, that value is the estimated standard deviation not the estimated variance. Regards, Christoph Buser -- Christoph Buser [EMAIL PROTECTED] Seminar fuer Statistik, LEO C13 ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-44-632-4673 fax: 632-1228 http://stat.ethz.ch/~buser/ -- Rick DeShon writes: Hi All. I need a bit of help extracting the residual error variance from the VarCorr structure from lmer. #Here's a 2-way random effects model lmer.1- lmer(rating ~ (1|person)+(1|rater), data = dat) #Get the structure vc.fit - VarCorr(lmer.1) #results in. $person 1 x 1 Matrix of class dpoMatrix (Intercept) (Intercept) 0.7755392 $rater 1 x 1 Matrix of class dpoMatrix (Intercept) (Intercept) 0.2054469 attr(,sc) [1] 0.5051518 #I can pull out the person and rater variance components easy enough. For example... vc.person - [EMAIL PROTECTED] I'm sure it's simple but I have not been able to grab the residual variance in the last matrix. I simply wish to asign the residual to a scalar variable. Any suggestions would be appreciated! Thanks! Rick DeShon -- Rick DeShon 306 Psychology Building Department of Psychology Michigan State University East Lansing, MI 48824-1116 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Extracting variance components from lmer
Hi Rick There may be a better way, but the following should work: attributes(vc.fit)$sc Regards, Christoph Buser -- Christoph Buser [EMAIL PROTECTED] Seminar fuer Statistik, LEO C13 ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-44-632-4673 fax: 632-1228 http://stat.ethz.ch/~buser/ -- Rick DeShon writes: Hi All. I need a bit of help extracting the residual error variance from the VarCorr structure from lmer. #Here's a 2-way random effects model lmer.1- lmer(rating ~ (1|person)+(1|rater), data = dat) #Get the structure vc.fit - VarCorr(lmer.1) #results in. $person 1 x 1 Matrix of class dpoMatrix (Intercept) (Intercept) 0.7755392 $rater 1 x 1 Matrix of class dpoMatrix (Intercept) (Intercept) 0.2054469 attr(,sc) [1] 0.5051518 #I can pull out the person and rater variance components easy enough. For example... vc.person - [EMAIL PROTECTED] I'm sure it's simple but I have not been able to grab the residual variance in the last matrix. I simply wish to asign the residual to a scalar variable. Any suggestions would be appreciated! Thanks! Rick DeShon -- Rick DeShon 306 Psychology Building Department of Psychology Michigan State University East Lansing, MI 48824-1116 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Extracting variance components in lme
Consider the output for the inroductory Rail example in Mixed Effects Models in S and S-PLUS by Pinheiro and Bates: summary(fm1Rail.lme) Linear mixed-effects model fit by REML Data: Rail AIC BIC logLik 128.177 130.6766 -61.0885 Random effects: Formula: ~1 | Rail (Intercept) Residual StdDev:24.80547 4.020779 Fixed effects: travel ~ 1 Value Std.Error DF t-value p-value (Intercept) 66.5 10.17104 12 6.538173 0 Standardized Within-Group Residuals: Min Q1 Med Q3 Max -1.61882658 -0.28217671 0.03569328 0.21955784 1.61437744 Number of Observations: 18 Number of Groups: 6 I want to extract the variance components sigma = 4.020779 (the within component) and sigma_b = 24.80547 (the between component). I can get sigma easily: sigma - fm1Rail.lme$sigma but how can I get sigma_b ? Cheers, Murray Jorgensen -- Dr Murray Jorgensen http://www.stats.waikato.ac.nz/Staff/maj.html Department of Statistics, University of Waikato, Hamilton, New Zealand Email: [EMAIL PROTECTED]Fax 7 838 4155 Phone +64 7 838 4773 wkHome +64 7 825 0441Mobile 021 1395 862 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Extracting Variance Components fro lme
It seems that what I need to get the within group component is as.numeric(VarCorr(fm1Rail.lme)[2,2]) thanks to Bert Gunter and Peter Alspach. Murray Jorgensen -- Dr Murray Jorgensen http://www.stats.waikato.ac.nz/Staff/maj.html Department of Statistics, University of Waikato, Hamilton, New Zealand Email: [EMAIL PROTECTED]Fax 7 838 4155 Phone +64 7 838 4773 wkHome +64 7 825 0441Mobile 021 1395 862 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Extracting variance components in lme
v - VarCorr(fm1Rail.lme) str(v) # get an idea of how v is structured. This suggests: as.numeric(v[1, 2]) [1] 24.80547 There may be easier and better ways HTH, Simon. At 11:02 AM 3/11/2005, you wrote: Consider the output for the inroductory Rail example in Mixed Effects Models in S and S-PLUS by Pinheiro and Bates: summary(fm1Rail.lme) Linear mixed-effects model fit by REML Data: Rail AIC BIC logLik 128.177 130.6766 -61.0885 Random effects: Formula: ~1 | Rail (Intercept) Residual StdDev:24.80547 4.020779 Fixed effects: travel ~ 1 Value Std.Error DF t-value p-value (Intercept) 66.5 10.17104 12 6.538173 0 Standardized Within-Group Residuals: Min Q1 Med Q3 Max -1.61882658 -0.28217671 0.03569328 0.21955784 1.61437744 Number of Observations: 18 Number of Groups: 6 I want to extract the variance components sigma = 4.020779 (the within component) and sigma_b = 24.80547 (the between component). I can get sigma easily: sigma - fm1Rail.lme$sigma but how can I get sigma_b ? Cheers, Murray Jorgensen -- Dr Murray Jorgensen http://www.stats.waikato.ac.nz/Staff/maj.html Department of Statistics, University of Waikato, Hamilton, New Zealand Email: [EMAIL PROTECTED]Fax 7 838 4155 Phone +64 7 838 4773 wkHome +64 7 825 0441Mobile 021 1395 862 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Extracting variance components in lme
Woops! I should have written: as.numeric(VarCorr(fm1Rail.lme)[1,2]) for the within component. -- Dr Murray Jorgensen http://www.stats.waikato.ac.nz/Staff/maj.html Department of Statistics, University of Waikato, Hamilton, New Zealand Email: [EMAIL PROTECTED]Fax 7 838 4155 Phone +64 7 838 4773 wkHome +64 7 825 0441Mobile 021 1395 862 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Extracting Variance Components
Mike, use --- VarCorr(lme.object) or for a user friendly output use varcomp from the 'ape' package-- require(ape) varcomp(lme.object) varcomp also allows scaling of components to unity (*100 gives %) and also allows for cumulative sum of components. Note. varcomp doesn't work for lmer objects. HTH, John -- Michel Friesenhahn wrote- Dear List, Is there a way to extract variance components from lmeObjects or summary.lme objects without using intervals()? For my purposes I don't need the confidence intervals which I'm obtaining using parametric bootstrap. Thanks, Mike __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Extracting Variance Components
Dear List, Is there a way to extract variance components from lmeObjects or summary.lme objects without using intervals()? For my purposes I don't need the confidence intervals which I'm obtaining using parametric bootstrap. Thanks, Mike [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Extracting Variance Components
?VarCorr At 12:02 PM 27/10/2005, you wrote: Dear List, Is there a way to extract variance components from lmeObjects or summary.lme objects without using intervals()? For my purposes I don't need the confidence intervals which I'm obtaining using parametric bootstrap. Thanks, Mike [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Simon Blomberg, B.Sc.(Hons.), Ph.D, M.App.Stat. Centre for Resource and Environmental Studies The Australian National University Canberra ACT 0200 Australia T: +61 2 6125 7800 email: Simon.Blomberg_at_anu.edu.au F: +61 2 6125 0757 CRICOS Provider # 00120C __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html