Toby Gardner
2006-Sep-11 22:38 UTC
[R] Extracting overdispersion estimates from lmer amd glm objects
Dear list, I am needing to extract the estimate of overdispersion (deviance / residual degrees of freedom or c-hat) from multiple model objects - so they can then be used to compare the extent of overdispersion among alternative models as well as calculate qausi-AIC values. I have been unable to do this, despite consulting a number of manuals and searching the R-help. I am imaging that in theory it should be possible with some call to attr(), but i have so far had no success. An example model output would be:> modeltest<-lmer(Coleodactylus_amazonicus_N~USD + (1|site),data=SFArray,family=poisson,method="Laplace",control=list(usePQL=FALSE, msVerbose=TRUE)) > summary(modeltest)------------ Generalized linear mixed model fit using Laplace Formula: Coleodactylus_amazonicus_N ~ USD + (1 | site) Data: SFArray Family: poisson(log link) AIC BIC logLik deviance 75.94996 81.68603 -34.97498 69.94996 Random effects: Groups Name Variance Std.Dev. site (Intercept) 2.6076 1.6148 number of obs: 50, groups: site, 5 Estimated scale (compare to 1) 1.080798 ------------ What I need is to extract this value (1.080798) from multiple lmer objects. Has anyone any recommendations? I also need to do this for glm objects although I suspect if someone was able to kindly point me in the right direction then the solution is likely to be similar. Very many thanks, Toby Gardner> sessionInfo()Version 2.3.1 (2006-06-01) i386-pc-mingw32 attached base packages: [1] "datasets" "graphics" "grDevices" "methods" "stats" "utils" "base" other attached packages: JGR iplots JavaGD lme4 Matrix lattice MASS rJava "1.4-7" "1.0-3" "0.3-4" "0.995-2" "0.995-15" "0.13-8" "7.2-27.1" "0.4-6" School of Environmental Sciences University of East Anglia Norwich, NR4 7TJ United Kingdom Email: t.gardner@uea.ac.uk Website: www.uea.ac.uk/~e387495 [[alternative HTML version deleted]]
Simon Blomberg
2006-Sep-12 06:53 UTC
[R] Extracting overdispersion estimates from lmer amd glm objects
summary(modeltest)@sigma Toby Gardner wrote:> Dear list, > > I am needing to extract the estimate of overdispersion (deviance / residual degrees of freedom or c-hat) from multiple model objects - so they can then be used to compare the extent of overdispersion among alternative models as well as calculate qausi-AIC values. I have been unable to do this, despite consulting a number of manuals and searching the R-help. I am imaging that in theory it should be possible with some call to attr(), but i have so far had no success. > > An example model output would be: > > >> modeltest<-lmer(Coleodactylus_amazonicus_N~USD + (1|site),data=SFArray,family=poisson,method="Laplace",control=list(usePQL=FALSE, msVerbose=TRUE)) >> summary(modeltest) >> > > ------------ > > Generalized linear mixed model fit using Laplace > Formula: Coleodactylus_amazonicus_N ~ USD + (1 | site) > Data: SFArray > Family: poisson(log link) > AIC BIC logLik deviance > 75.94996 81.68603 -34.97498 69.94996 > Random effects: > Groups Name Variance Std.Dev. > site (Intercept) 2.6076 1.6148 > number of obs: 50, groups: site, 5 > > Estimated scale (compare to 1) 1.080798 > > ------------ > > What I need is to extract this value (1.080798) from multiple lmer objects. Has anyone any recommendations? I also need to do this for glm objects although I suspect if someone was able to kindly point me in the right direction then the solution is likely to be similar. > > Very many thanks, > > Toby Gardner > > >> sessionInfo() >> > Version 2.3.1 (2006-06-01) > i386-pc-mingw32 > > attached base packages: > [1] "datasets" "graphics" "grDevices" "methods" "stats" "utils" "base" > > other attached packages: > JGR iplots JavaGD lme4 Matrix lattice MASS rJava > "1.4-7" "1.0-3" "0.3-4" "0.995-2" "0.995-15" "0.13-8" "7.2-27.1" "0.4-6" > > > School of Environmental Sciences > University of East Anglia > Norwich, NR4 7TJ > United Kingdom > Email: t.gardner at uea.ac.uk > Website: www.uea.ac.uk/~e387495 > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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 > and provide commented, minimal, self-contained, reproducible code. > >-- 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 The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. - John Tukey.
David Barron
2006-Sep-12 07:55 UTC
[R] Extracting overdispersion estimates from lmer amd glm objects
You can extract it from a summary.lmer object, which has a slot names "sigma" that contains this scale parameter. For example,> sum.modeltest <- summary(modeltest) > sum.modeltest at sigmaOn 11/09/06, Toby Gardner <t.gardner at uea.ac.uk> wrote:> Dear list, > > I am needing to extract the estimate of overdispersion (deviance / residual degrees of freedom or c-hat) from multiple model objects - so they can then be used to compare the extent of overdispersion among alternative models as well as calculate qausi-AIC values. I have been unable to do this, despite consulting a number of manuals and searching the R-help. I am imaging that in theory it should be possible with some call to attr(), but i have so far had no success. > > An example model output would be: > > > modeltest<-lmer(Coleodactylus_amazonicus_N~USD + (1|site),data=SFArray,family=poisson,method="Laplace",control=list(usePQL=FALSE, msVerbose=TRUE)) > > summary(modeltest) > > ------------ > > Generalized linear mixed model fit using Laplace > Formula: Coleodactylus_amazonicus_N ~ USD + (1 | site) > Data: SFArray > Family: poisson(log link) > AIC BIC logLik deviance > 75.94996 81.68603 -34.97498 69.94996 > Random effects: > Groups Name Variance Std.Dev. > site (Intercept) 2.6076 1.6148 > number of obs: 50, groups: site, 5 > > Estimated scale (compare to 1) 1.080798 > > ------------ > > What I need is to extract this value (1.080798) from multiple lmer objects. Has anyone any recommendations? I also need to do this for glm objects although I suspect if someone was able to kindly point me in the right direction then the solution is likely to be similar. > > Very many thanks, > > Toby Gardner > > > sessionInfo() > Version 2.3.1 (2006-06-01) > i386-pc-mingw32 > > attached base packages: > [1] "datasets" "graphics" "grDevices" "methods" "stats" "utils" "base" > > other attached packages: > JGR iplots JavaGD lme4 Matrix lattice MASS rJava > "1.4-7" "1.0-3" "0.3-4" "0.995-2" "0.995-15" "0.13-8" "7.2-27.1" "0.4-6" > > > School of Environmental Sciences > University of East Anglia > Norwich, NR4 7TJ > United Kingdom > Email: t.gardner at uea.ac.uk > Website: www.uea.ac.uk/~e387495 > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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 > and provide commented, minimal, self-contained, reproducible code. >-- ================================David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP
David Barron
2006-Sep-12 08:26 UTC
[R] Extracting overdispersion estimates from lmer amd glm objects
PS, the equivalent for a glm is:> sum.modeltest <- summary(modeltest) > sum.modeltest$dispersionHope this helps. On 11/09/06, Toby Gardner <t.gardner at uea.ac.uk> wrote:> Dear list, > > I am needing to extract the estimate of overdispersion (deviance / residual degrees of freedom or c-hat) from multiple model objects - so they can then be used to compare the extent of overdispersion among alternative models as well as calculate qausi-AIC values. I have been unable to do this, despite consulting a number of manuals and searching the R-help. I am imaging that in theory it should be possible with some call to attr(), but i have so far had no success. > > An example model output would be: > > > modeltest<-lmer(Coleodactylus_amazonicus_N~USD + (1|site),data=SFArray,family=poisson,method="Laplace",control=list(usePQL=FALSE, msVerbose=TRUE)) > > summary(modeltest) > > ------------ > > Generalized linear mixed model fit using Laplace > Formula: Coleodactylus_amazonicus_N ~ USD + (1 | site) > Data: SFArray > Family: poisson(log link) > AIC BIC logLik deviance > 75.94996 81.68603 -34.97498 69.94996 > Random effects: > Groups Name Variance Std.Dev. > site (Intercept) 2.6076 1.6148 > number of obs: 50, groups: site, 5 > > Estimated scale (compare to 1) 1.080798 > > ------------ > > What I need is to extract this value (1.080798) from multiple lmer objects. Has anyone any recommendations? I also need to do this for glm objects although I suspect if someone was able to kindly point me in the right direction then the solution is likely to be similar. > > Very many thanks, > > Toby Gardner > > > sessionInfo() > Version 2.3.1 (2006-06-01) > i386-pc-mingw32 > > attached base packages: > [1] "datasets" "graphics" "grDevices" "methods" "stats" "utils" "base" > > other attached packages: > JGR iplots JavaGD lme4 Matrix lattice MASS rJava > "1.4-7" "1.0-3" "0.3-4" "0.995-2" "0.995-15" "0.13-8" "7.2-27.1" "0.4-6" > > > School of Environmental Sciences > University of East Anglia > Norwich, NR4 7TJ > United Kingdom > Email: t.gardner at uea.ac.uk > Website: www.uea.ac.uk/~e387495 > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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 > and provide commented, minimal, self-contained, reproducible code. >-- ================================David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP