Re: [R] A quick question about lm()

From: Tobias Verbeke <tobias.verbeke_at_gmail.com>
Date: Mon, 07 Jul 2008 16:30:31 +0200

rlearner309 wrote:

> I have a simple regression using lm().

model <- lm(dist ~ speed, data = cars)
sModel <- summary(model)

> If I just want to check the coefficient, I can use summary(lm())$coef; if I
> need the standard error, I can use summary(lm())$s, if I need the residuals,

It is recommended to extract the information using coef() or resid() as in

coef(model) # or coefficients(model)
resid(model) # or residuals(model)

> I can use summary(lm())$res. OK. How can I get the R-squares and Adjusted
> R-squares using $...?
> Is there a function, like objects(), that can show all the references for
> values?

str(sModel)

sModel$r.squared
sModel$adj.r.squared

HTH,
Tobias



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. Received on Mon 07 Jul 2008 - 14:50:39 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 07 Jul 2008 - 15:01:51 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive