Reputation: 11
I would like to export the standard errors and also the p.values of the regression coefficients from a model. In addition, I would like the starts to appear on the se and the p values. For this I should specify the override.se and override.pvalues. When I use those however, the texreg output doesn't seem to be changing. I think that these functions are somehow not recognised in my texreg. I installed the latest version of the package but my output is not changing.
Here is my code to test this:
library(texreg)
model <- lm(mpg ~ wt + hp + qsec, data = mtcars)
se <- summary(model)$coefficients[, 2]
p_val <- summary(model)$coefficients[, 4]
# Output
texreg(model,
override.se = se,
override.pvalues = p_val)
### For me here the p-values don't apper underneath the se-s.
# this is what I use to have stars on the se-s
# Add stars based on p-values
add_stars <- function(se, p) {
if (p < 0.001) {
return(paste0("(", round(se, 3),")***"))
} else if (p < 0.01) {
return(paste0("(", round(se, 3),")**"))
} else if (p < 0.05) {
return(paste0("(", round(se, 3),")*"))
} else {
return(paste0("(", round(se, 3),")"))
}
}
se_stars <- mapply(add_stars, se, p_val)
texreg(model,
override.se = se_stars,
override.pvalues = p_val,
stars = numeric(0))
# In this outout there are no starts at all, I specify stars = numeric(0) in texreg, but the stars should have appeared on the se-s; also the p.values are not in the output.)
Any idea how can I have both the se and p-values reported in my output, and both with stars?
Upvotes: 0
Views: 48