5

I have made this model selection table:

lm_mtcars <- lm(mpg ~ drat + hp + wt, mtcars)

library(MuMIn)
mod_sel_lm_mtcars <- (mod.sel(lm_mtcars))

mod_sel_lm_mtcars

Model selection table 
          (Intrc)  drat       hp     wt df  logLik AICc delta weight
lm_mtcars   29.39 1.615 -0.03223 -3.228  5 -73.366  159     0      1

I can get stargazer to convert it to a latex table:

library(stargazer)
stargazer(mod_sel_lm_mtcars)

How can I get stargazer to print variable names as in Coulombe Et Al 2011, p288, Table 2.

Therefore:

  1. df should be renamed to k (in italics)
  2. delta should be renamed to [latex symbol \Delta] AICc
  3. weight should be renamed to w[subscript i]
luciano
  • 13,158
  • 36
  • 90
  • 130
  • 1
    Try just replacing the colnames using `names(mod_sel_lm_mtcars)[c(5,8,9)] <- c('\\emph{k}','$\\delta$ AICc','$w_i$')`. The result seems to cause `stargazer` to error; but its output is not what you want anyway since it's running summary on the dataframe. Try just using `xtable::xtable(mod_sel_lm_mtcars)`, which gets you close. `stargazer` is great for models, but not for dataframes, which is the type of object you have here. – Thomas Apr 10 '14 at 12:49

1 Answers1

5

You can use the covariate.labels argument. for this (As you didn't make clear which rows you wanted to keep in the output, I assumed you wanted them all, but you can change that as well using the keep argument.)

stargazer(mod_sel_lm_mtcars, 
      covariate.labels = 
        c("(Intercept)", "drat", "hp", "$w_{i}$",
          "\\textit{k}", "logLik", "AICc", "\\Delta AICc"))
BeSeLuFri
  • 623
  • 1
  • 5
  • 21
Lucas De Abreu Maia
  • 598
  • 2
  • 6
  • 19