Skip to content
Prev 5486 / 29559 Next

Help to save the value of "Multiple R-Squared" in a a simple regression model

On Sun, Apr 12, 2009 at 10:23 AM, gianni lavaredo
<gianni.lavaredo at gmail.com> wrote:
Hi Gianni,

For a 'simple' regression

r2 <- cor(y,x)^2

More generally, names(summary(MyModel)) will tell you the names of the
objects in the list produced by summary.lm -- or use the 'str'
function to see a summary of the structure of the object. Since the
R-squared list element is named 'r.squared' it can be extracted with

r2 <- summary(myModel)$r.squared

As for making a data frame or list object,

lst <- list(r2)
or
df <- data.frame(r2)

Buona Pasqua,

Kingsford Jones