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

Duncan Murdoch murdoch at stats.uwo.ca
Sun Apr 5 14:00:18 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. 

Sorry, I misread your question:  the p-value of that statistic isn't 
returned.  You just need to calculate it yourself, as

  f <- x$fstatistic
  pf(f[1], f[2], f[3], lower=FALSE)

Duncan Murdoch




More information about the R-help mailing list