Dear all, I cannot find to explicitly get the R-squared or adjusted R-squared from summary(lm()) Thanks a lot! [[alternative HTML version deleted]]
Trafim Vanishek wrote:> Dear all, > > I cannot find to explicitly get the R-squared or adjusted R-squared from > summary(lm()) > > Thanks a lot! > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org 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. >See the documentation for summary.lm (?summary.lm): summary(lm(speed~dist, cars)) attributes(summary(lm(speed~dist, cars))) # Get the R^2 summary(lm(speed~dist, cars))$r.squared summary(lm(speed~dist, cars))$adj.r.squared cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul
Hi Trafim, Take a look at the following example: set.seed(123) x <- runif(100) y <- 3 + 1.5*x + rnorm(100) fit <- lm(y ~ x) summary(fit) str(summary(fit)) summary(fit)$r.squared HTH, Jorge On Fri, Jan 22, 2010 at 10:10 AM, Trafim Vanishek <> wrote:> Dear all, > > I cannot find to explicitly get the R-squared or adjusted R-squared from > summary(lm()) > > Thanks a lot! > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org 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. >[[alternative HTML version deleted]]
On 1/22/2010 10:10 AM, Trafim Vanishek wrote:> Dear all, > > I cannot find to explicitly get the R-squared or adjusted R-squared from > summary(lm())fm1 <- lm(Sepal.Length ~ Sepal.Width, data=iris) summary(fm1) str(summary(fm1)) summary(fm1)$r.squared ?str> Thanks a lot! > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org 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.-- Chuck Cleland, Ph.D. NDRI, Inc. (www.ndri.org) 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894
Trafim Vanishek wrote:> Dear all, > > I cannot find to explicitly get the R-squared or adjusted R-squared from > summary(lm()) >> names(summary(RegModel.1))[1] "call" "terms" "residuals" "coefficients" [5] "aliased" "sigma" "df" "r.squared" [9] "adj.r.squared" "fstatistic" "cov.unscaled"> summary(RegModel.1)$r.squared[1] 0.55389> summary(RegModel.1)$adj.r.squared[1] 0.5432683 -- O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907