Home > Enterprise >  Formatting regression results in R for latex
Formatting regression results in R for latex

Time:07-13

I am trying to create a regression results table in R for latex. I would like this table to have two separate columns: one for the estimates and one for the standard error. The following code

library(fixest)
library(car)
library(pander)

##Using the built-in CO2 data frame, run regression

i<- feols(conc ~ uptake   Treatment | Type, CO2, vcov = "hetero")
summary(i)

##Create regression table for latex

etable(i, postprocess.df = pandoc.table.return, style = "rmarkdown")

my_style = style.df(depvar.title = "", fixef.title = "",
                    fixef.suffix = " fixed effect", yesNo = "yes", default = TRUE)
setFixest_etable(style.df = my_style, postprocess.df = pandoc.table.return)

etable(i, style = "rmarkdown", caption = "New default values", se.below = NULL )

etable(i, tex = TRUE)

print(etable(i, tex = TRUE), file = "filename2.tex")

When put into Latex document on overleaf.com the following image is produced. enter image description here

How can I alter my above code to have estimates and standard error in different columns in my table?

CodePudding user response:

You can try the following:

modelsummary(your_regression, fmt=2, 
             estimate = c("{estimate}{stars} (std.error)"), 
             statistic = c(),
             output = "latex") 

What I like with modelsummary too, is that it enable to put many different model as a list to compare them.

CodePudding user response:

Thanks to @léo-henry for suggesting modelsummary. I just wanted to point out that in the latest version of the package you can use the shape argument to display the estimates and standard errors (or other statitics) side-by-side. You will find details here: enter image description here

  • Related