extract the p value of F statistics from the lm class
On 05-Apr-09 08:18:27, 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.
Thanks
Ted
Maybe you were looking in the wrong place. A few lines above the
output from x$fstatistic
x$fstatistic
value numdf dendf
72.04064 1.00000 31.00000
you will find
F-statistic: 72.04 on 1 and 31 DF, p-value: 1.379e-09
and therefore will find the P-value. However, maybe that is not
the question you really wanted to ask. If that is what I think it
may be, you could
1: Observe that x$fstatistic is a vector with 3 values which
are: value of F; numerator df; demoninator df
2: Note (from ?pf)
pf(q, df1, df2, ncp, lower.tail = TRUE, log.p = FALSE)
3: Therefore do
pf(x$fstatistic[1],x$fstatistic[2],x$fstatistic[3],lower.tail=FALSE)
# [1] 1.378626e-09
Note that the P-value is not in the list of values returned by lm()
although $fstatistic is one of the values. The computation of the
P-value in the displayed output from summary.lm() is done by the
'print' method for summary.lm() (just as in [3] above).
Hoping this helps,
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 05-Apr-09 Time: 13:12:45
------------------------------ XFMail ------------------------------