Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stargazer producing various latex errors

I am using stargazer to output regression results from r to latex. When I run the output in latex I see the results, but get many Package array errors. Here is my code. In R I use stargazer as follows:

stargazer(fe1, fe2, fe3,
               title="Between regression",
               align=TRUE, 
               df = FALSE, 
               dep.var.labels=c('depLabel'), 
               covariate.labels = c('1st', '2nd', '3rd', '4th') )

This produces many errors in latexthat look like:

Package array Error: Illegal pream-token (D): `c' used. ...5pt}}lD{.}{.}{-3} D{.}{.}{-3} D{.}{.}{-3} }
Package array Error: Illegal pream-token (.): `c' used. ...5pt}}lD{.}{.}{-3} D{.}{.}{-3} D{.}{.}{-3} }
Package array Error: Illegal pream-token (-3): `c' used. ...5pt}}lD{.}{.}{-3} D{.}{.}{-3} D{.}{.}{-3} }

and also many Missing $ inserted errors. Is there perhaps any package I need to add to my latex preamble? Or any other common workaround?

Edit Here are the last lines of the dput of fe1:

"31495", "31496", "31497", "31498", "31499", "31500"), class = c("pindex", 
"data.frame"))), assign = c(0L, 1L, 1L), args = structure(list(
    model = "within", effect = "time", random.method = "swar", 
    random.dfcor = NULL, inst.method = "bvk"), .Names = c("model", 
"effect", "random.method", "random.dfcor", "inst.method")), aliased = structure(c(FALSE, 
FALSE), .Names = c("X1Dq", "X1DT")), call = plm(formula = Y1 ~ 
    X1, data = pdata1, effect = "time", model = "within")), .Names = c("coefficients", 
"vcov", "residuals", "df.residual", "formula", "model", "assign", 
"args", "aliased", "call"), class = c("plm", "panelmodel"))
like image 842
splinter Avatar asked Dec 13 '22 23:12

splinter


1 Answers

I found the way to solve it by digging in the documentation: make sure to add \usepackage{dcolumn} in the latex preamble. Then I don't get any errors when compiling in latex.

like image 134
splinter Avatar answered Jan 04 '23 04:01

splinter