Reputation: 1
Given a regression, undertaken in R; namely :
regfit <- lm(y ~ x, cricketData)
with the last line of summary(regfit)
being :
F-statistic: 29.97 on 1 and 13 DF, p-value: 0.0001067
is it possible to obtain merely the values of the F-statistic and the p-value?
summary (regfit)$fstatistic[1]
returns :| value| which is not what I intend. | 29.97|
Similarly for print (pf(Fstat[1], Fstat[2], Fstat[3], lower.tail=FALSE))
which
prints the p-value beneath the word "value".
Is it possible to obtain the numeric value per se or is there a means to repress the world "value" and obtain the numeric value?
Upvotes: 0
Views: 441
Reputation: 79228
You could simply extract the value without the name:
summary(regfit)$fstatistic[[1]]
For the p-value:
pf(Fstat[[1]], Fstat[2], Fstat[3], lower.tail=FALSE)
Upvotes: 0
Reputation: 226192
You could also use broom::glance()
:
example("lm") ## to define lm.D90
library("broom")
glance(lm.D90)[,c("statistic", "p.value")]
Upvotes: 1
Reputation: 887158
It is a named vector
. Just do unname
to remove the name value
unname(pf(Fstat[1], Fstat[2], Fstat[3], lower.tail=FALSE))
similarly
unname(summary (regfit)$fstatistic[1])
Upvotes: 1