Josh B
2010-Jun-19 02:14 UTC
[R] Extracting P-values from the lrm function in the rms library
Hello again R users,
I have a devilishly hard problem, which should be very simple. I hope someone
out there will have the answer to this on the tip of their tongue.
Please consider the following toy example:
x <- read.table(textConnection("y x1 x2
indv.1 bagels 4 6
indv.2 donuts 5 1
indv.3 donuts 1 10
indv.4 donuts 10 9
indv.5 bagels 0 2
indv.6 bagels 2 9
indv.7 bagels 8 5
indv.8 bagels 4 1
indv.9 donuts 3 3
indv.10 bagels 5 9
indv.11 bagels 9 10
indv.12 bagels 3 1
indv.13 donuts 7 10
indv.14 bagels 2 10
indv.15 bagels 9 6"), header = TRUE)
I am fitting a polynomial model to this dataset, namely:
mod.poly3 <- lrm(y ~ pol(x1, 3) + pol(x2, 3), data=x)
Here's my problem. If I look at the output, I can see a list of P-values
(try typing "mod.poly3" and enter to see what I mean). But... how do I
access this list of P-values? What I mean is, how can I "liberate"
this list of P-values from the full output? How do I turn that list of P-values
into a vector, for example, that I can save off to a file, by itself?
Specific code that gets the job done is what I'm after. Be wary of the
anova() command. It gives DIFFERENT output than what I want. I want EXACTLY the
list of P-values I see when I type "mod3.poly" and enter.
I have googled this problem, and none of the answers actually give me the output
I'm asking for here.
Specifically, I found these links -- all dead-ends:
https://stat.ethz.ch/pipermail/r-help/2005-August/078210.html <== Nope.
Doesn't give right output.
http://r.789695.n4.nabble.com/extracting-p-value-from-an-lrm-object-td854071.html
<== Nope. The output is different.
http://www.mathkb.com/Uwe/Forum.aspx/stat-consult/1381/Extracing-p-values-from-lrm-object
<== Nope. Wrong output.
Can anyone crack this seemingly simple problem? Surprisingly the answer was not
revealed using str(mod3.poly) either.
Thanks in advance,
-----------------------------------
Josh Banta, Ph.D
Center for Genomics and Systems Biology
New York University
100 Washington Square East
New York, NY 10003
Tel: (212) 998-8465
http://plantevolutionaryecology.org
[[alternative HTML version deleted]]
Christos Argyropoulos
2010-Jun-19 11:45 UTC
[R] Extracting P-values from the lrm function in the rms library
Hi, mod.poly3$coef/sqrt(diag(mod.poly3$var)) will give you the Wald stat values, so pnorm(abs(mod.poly3$coef/sqrt(diag(mod.poly3$var))),lower.tail=F)*2 will yield the corresponding p-vals Christos Argyropoulos _________________________________________________________________ Hotmail: Trusted email with powerful SPAM protection.
Seemingly Similar Threads
- Continuing on with a loop when there's a failure
- Splitting a data frame into several completely separate data frames
- Nesting functions in loops that result in error messages breaking the loop
- Fitting a polynomial using lrm from the Design library
- Paste and namespace