I can extract the p-values for my slope & intercept from an ols object this way:
library(rms)
m1 <- ols(wt ~ cyl, data= mtcars, x= TRUE, y= TRUE)
coef(summary.lm(m1))
But when I try the same thing with a robcov object, summary.lm gives me the p-values from the original model (m1), not the robcov model:
m2 <- robcov(m1)
m2
coef(summary.lm(m2))
I think this must be related to the Warning from the robcov help page,
Warnings
Adjusted ols fits do not have the corrected standard errors printed
with print.ols. Use sqrt(diag(adjfit$var)) to get this, where adjfit
is the result of robcov.
but I’m not sure how.
Is there a way to extract the p-values from a robcov object? (I’m really only interested in the one for the slope, if that makes a difference…)
Hacking through
print.olsandprModFit, I came up with this.Change m2 to another robcov model.
Try it for yourself by comparing the results of
Ptoprint(m2)