OK, what is the trick to extracting the overall p value from an lm object?
It shows up in the summary(lm(model)) output but I can't seem to extract it:
test2 = apply(aa, 1, function(x) summary(lm(x[,1] ~ 0 + x[,3] + x[,6])))
test2[[1]]
Call:
lm(formula = x[, 1] ~ 0 + x[, 3] + x[, 6])
[omitted
Hi Jim,
Its a bit of a trick question. There isn't actually any overall p
value stored in the lm object, or even in the summary.lm object. It
is calculated from the f statistic by the print methods for
summary.lm. Of course, none of that helps, per se. Try this:
summary(lm(mpg ~ hp, data =
It's not directly extractable since it's calculated on the fly in the
printing method. If you type stats:::print.summary.lm, you can see
the code the leads to the calculation: It's basically (I'm leaving out
some formatting stuff):
pf(x$fstatistic[1L], x$fstatistic[2L], x$fstatistic[3L],
On 24/10/2011 1:47 PM, Jim Bouldin wrote:
OK, what is the trick to extracting the overall p value from an lm object?
It shows up in the summary(lm(model)) output but I can't seem to extract it:
It's not part of the object, it is computed when the object is printed.
To see the print method,
I’m trying to do multiply permutation tests, my code look like:
one.test- function(x,y){
+ xstar-sample(x)
+ anova(lm(y ~ xstar))
+ }
z-function(x) replicate (1000,one.test(x,BPH)$F value[1]) # gives me
1000 permute F values
perm_Fvalue- apply(assoc_BPH[,3:900],2,z)
a - function(x)
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
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
Hi,
what about the following:
## some test data
x - 1:10
y - x + rnorm(x)
## model and summary
m - lm(y~x)
sm - summary(m)
sm
# str(sm)
# sm$fstatistic
## and now: the manual case
1 - pf(sm$fstatistic[1], sm$fstatistic[2], sm$fstatistic[3])
Hope it helps, ThPe
tedzzx schrieb:
Dear R
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
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
10 matches
Mail list logo