[R] Obtaining the adjusted r-square given the regression
Keith Chamberlain
Keith.Chamberlain at colorado.edu
Thu Jan 12 12:33:01 CET 2006
Hi people,
I want to obtain the adjusted r-square given a set of coefficients (without
the intercept), and I don't know if there is a function that does it.
Exist????????????????
Dear Alexandra,
Without knowing what routine you were using that returned an R-Square value
too you, it is a little difficult to tell. I am not able to comment on your
routine, but I'll try to give a satisfactory response to your first
question.
Assuming that you used lm() for your linear regression, then all you need to
do is see the help page for the lm() summary method, which explains how to
get at the values in the summary. In your console type the following:
>?summary.lm
That help page describes how to get at the values in the summary, and
provides an example with getting the full correlation value (whereas the one
printed is in a 'pretty' form). I assume the other ones can be accessed
similarly, including the adjusted R^2. Your code might look something like
the following:
# Where object is the result of a call to lm()
>summary(object)$adj.r.squared
The help also has a demonstration for how to exclude the intercept, where
you simply add a -1 term too the end of your formula.
There may still be an accessor function available, which I do not know about
(BUT am certainly interested in if anyone has feedback).
In the future, it would help people on the list decode your function when it
too is printed in a readable form. The layout of your function in your
message may have become garbled when it was stripped of all of its HTML
information. If the code was formatted in a readable way when you sent the
message, then that's what happened. If that is the case try composing your
message in plain text to begin with.
I hope this helps.
Rgds,
KeithC.
More information about the R-help
mailing list