My question falls somewhere between this one and this one.
I want to add a line in the regression output for the reference category of a factor variable. Stargazer doesn't seem to have an easy way of doing this. My current approach is to add a line with add.lines
and then manually change the order of that new line, in my Word document. This is of course tedious.
x <- as.factor(c("a","b","c"))
x1 <- c(1,2,3)
# Estimate a model
m1 <- lm(x1~x)
#Create output
stargazer(m1, type = "text", style="ajs", add.lines=c("a (ref.)"))
This is where I stand now:
> stargazer(m1, type = "text", style="ajs", add.lines=c("a (ref.)"))
========================
X1
------------------------
xb 1.000
xc 2.000
Constant 1.000
a (ref.)
Observations 3
R2 1.000
------------------------
Notes: *P < .05
**P < .01
***P < .001
My desired output is this:
========================
X1
------------------------
a (ref.)
xb 1.000
xc 2.000
Constant 1.000
Observations 3
R2 1.000
------------------------
Notes: *P < .05
**P < .01
***P < .001
What's an automatic way of customising the order of an added line? Or, if you prefer, a more general question: What's an easy way of adding the reference category of factor variables in its correct order?