I'd like to add the control group mean to my regression tables in Stargazer
. My current idea is to replace the intercept with the control group mean and rename that term. I know how to replace the value of the intercept, but is there a way to rename the intercept term? It's often informative to replace the constant term with the control group mean.
library(stargazer)
attitude$treatment <- rbinom(n = 30, size = 1, prob = .5)
lm_model <- lm(rating ~ treatment + complaints + privileges + learning
+ raises + critical, data=attitude)
#add in control mean
control_mean <- mean(attitude[attitude$treatment == 0, "rating"])
lm_model[["coefficients"]][names(lm_model[["coefficients"]]) ==
"(Intercept)"] <- control_mean
stargazer(lm_model)
This isn't really a
stargazer
question, but is just a matter of how to modify a model object.