[R] Accessing specific values of linear regression model
Liaw, Andy
andy_liaw at merck.com
Thu Mar 23 20:56:26 CET 2006
You said you were fitting regression model, yet you used
summary(aov(model))? It's rather unusual to use aov() for regression
models...
If you used lm() to fit the regression model, the following might help:
> y <- rnorm(10); x <- runif(10)
> fit <- lm(y ~ x)
> anova(fit)
Analysis of Variance Table
Response: y
Df Sum Sq Mean Sq F value Pr(>F)
x 1 1.2526 1.2526 1.6872 0.2302
Residuals 8 5.9397 0.7425
> str(anova(fit))
Classes anova and `data.frame': 2 obs. of 5 variables:
$ Df : int 1 8
$ Sum Sq : num 1.25 5.94
$ Mean Sq: num 1.253 0.742
$ F value: num 1.69 NA
$ Pr(>F) : num 0.23 NA
- attr(*, "heading")= chr "Analysis of Variance Table\n" "Response: y"
> anova(fit)["x", "Sum Sq"]
[1] 1.252643
Andy
From: Kelly Vincent
>
> I am just starting to learn R, and I'm struggling with a lot
> of the basic
> stuff. The online documentation is generally good, but I have
> been unable to
> find the answer for my problem this time.
>
> I am running linear regression on a particular set of data
> and plotting it.
> I've got the regression line plotted and everything is fine
> so far, except
> for one thing: I want to display the SSE from the regression
> and I don't
> know how to access it. In my script I have:
> model <- lm(y~x)
> and I was able to get the r^2 value that I wanted with:
> summary(model)$r.squared But I don't know how to get the SSE.
> When I print the summary(aov(model)) I
> get the following:
> Df Sum Sq Mean Sq F value Pr(>F)
> x 1 1793928 1793928 67.463 3.447e-11 ***
> Residuals 56 1489118 26591
> ---
> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
>
> So it's there (I can see it!) but how do I get to it? Any
> help would be much
> appreciated.
>
> Thanks,
> Kelly
>
> ______________________________________________
> 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
>
>
More information about the R-help
mailing list