[R] p-value from lm

Guido Masarotto guido at hal.stat.unipd.it
Tue Nov 23 22:17:35 CET 1999


On Tue, Nov 23, 1999 at 03:00:42PM -0500, Adam Kornick wrote:
> I'd like to automatically plot the p-value and r^2 of a linear model.
> I know that I can extract r^2 with 
> 
> foo <- lm(y~x)
> a <- summary(foo)
> a$r.squared
> 
> I can't find any similar functionality to obtain the p-value based on
> the ftest
> 
> a$fstatistic returns the actual f-test and df, but not the p-value.
> 
> Any thoughts?
> 

  You can use directly the F distribution function (pf). E.g.
  
  f.stat <- a$fstatistic
  p.value <- 1-pf(f.stat["value"],f.stat["numdf"],f.stat["dendf"])

  guido
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list