1
votes

The image below demonstrates what I am trying to output from R into LaTeX. I'm willing to use any approach/package that works.

Desired TeX output

As you can see in the image, the desired output has multiple models (the columns) and multiple regressions (the rows).

I have three hurdles:

First, how can I output standard errors from two different models below one point estimate? Neither of the SEs I seek to present are the conventional SEs; both are modified cluster-robust SEs calculated after I run the regression by using custom coeftest() functions, and outputting a coeftest object.

Second, how can I present the stars? I have devised a workaround in R to output the point estimate with the two SE calculations below it, but not with the stars automatically transferred as something like xtable or stargazer does.

Third, I would like to output only the point estimate and standard errors for the treatment variable. As you can see at the bottom of the table, in models (2) & (4) there are control variables, but I do not want to display any further information about them.

Also, it is worth noting that my output is not an lm object, but instead a coeftest object, which is stargazer-compatible but not xtable-compatible.

1

1 Answers

2
votes

Take a look at texreg, you will need to modify the latext code, inserting the code you want.

library("texreg");library(lmtest);library("sandwich")
library(nlme)

m1<-lm(distance ~ age, data = Orthodont)
coeftest(m1, vcov=sandwich)

m2<-lm(distance ~ age + Sex, data = Orthodont)
coeftest(m2, vcov=sandwich)

test1=texreg(list(m1,m2),caption="Models",
               label="Compmod",stars=c(0.05, 0.01))
#cat(test1)

model.1 <- lme(distance ~ age, data = Orthodont, random = ~ 1)
model.2 <- lme(distance ~ age + Sex, data = Orthodont, random = ~ 1)
texreg(list(m1,m2,model.1, model.2),caption="Models",
         label="Compmod", booktabs = TRUE, dcolumn = TRUE)

enter image description here