[R] extract the p value of F statistics from the lm class

Duncan Murdoch murdoch at stats.uwo.ca
Sun Apr 5 13:48:01 CEST 2009


On 05/04/2009 4:18 AM, tedzzx wrote:
> Dear R users
> 
> I have run an regression and want to extract the p value of the F
> statistics, but I can find a way to do that.
> 
> x<-summary(lm(log(RV2)~log(IV.m),data=b))
> 
> Call:
> lm(formula = log(RV2) ~ log(IV.m), data = b[[11]])
> 
> Residuals:
>      Min       1Q   Median       3Q      Max 
> -0.26511 -0.09718 -0.01326  0.11095  0.29777 
> 
> Coefficients:
>             Estimate Std. Error t value Pr(>|t|)    
> (Intercept)  -0.3059     0.1917  -1.595    0.121    
> log(IV.m)     0.9038     0.1065   8.488 1.38e-09 ***
> ---
> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
> 
> Residual standard error: 0.1435 on 31 degrees of freedom
> Multiple R-squared: 0.6991,	Adjusted R-squared: 0.6894 
> F-statistic: 72.04 on 1 and 31 DF,  p-value: 1.379e-09 
> 
> names(x)
>  [1] "call"          "terms"         "residuals"    
>  [4] "coefficients"  "aliased"       "sigma"        
>  [7] "df"            "r.squared"     "adj.r.squared"
> [10] "fstatistic"    "cov.unscaled"
> 
> x$fstatistic
>    value    numdf    dendf 
> 72.04064  1.00000 31.00000 
> 
> But can not find the p value of F statistics. 

If you're looking for something like that, the two places to look are:
  - the man page ?summary.lm (which gives the answer)
  - unclass(x) will display the object without the fancy printing, so 
you can see that the man page is accurate.  (Sometimes man pages are 
incomplete, and this way is needed, but not in this case.)

Duncan Murdoch




More information about the R-help mailing list