2

I am trying to run quite a few multinomial regression models. Stargazer seems like a great tool to report all results in one document for easy access. However, I noted that I get some negative confidence intervals, which does not make sense.

I tried using apply.coef=exp alone, where I got negative confidence intervals I also tried using apply.coef=exp and apply.ci=exp where the confidence interval does not make sense.

When I do apply.ci=exp by itself the CI are correct but it does not exponentiate the coefficient.

Health has 3 levels (poor, intermediate, ideal), poor is reference ETI is continuous.

test1 <- multinom(Health ~ ETI, data = X)
test2 <- multinom(Health ~ ETI + age + male, data = X)
test3 <- multinom(Health ~ ETI + age + male +educ +married+employed+income, data = X)
test4 <- multinom(Health ~ ETI + age + male +educ +married+depression+employed+income, data = X)

First code (only apply.coef)

stargazer(test1, test2, test3, test4, type="html", list(confint(test1, test2, test3, test4)),column.labels = c("Model1", "Model2", "Model3", "Model4"),column.separate = c(2,2,2,2), apply.coef=exp, out="X.htm")

The second code I tried (only apply.ci):

stargazer(test1, test2, test3, test4, type="html", apply.coef = exp  list(confint(test1, test2, test3, test4)),column.labels = c("Model1", "Model2", "Model3", "Model4"),column.separate = c(2,2,2,2), apply.ci=exp,apply.coef=exp, out="X.htm")

The last code (both apply.ci & apply.coef):

stargazer(test1, test2, test3, test4, type="html", apply.coef = exp  list(confint(test1, test2, test3, test4)),column.labels = c("Model1", "Model2", "Model3", "Model4"),column.separate = c(2,2,2,2), apply.ci=exp,apply.coef=exp, out="X.htm")

For the 1st code:

#        Ideal  Int 
#Model1 
#          (1)  (2) 
#ETI    0.453*  0.761***    
#(-0.051, 0.956)    (0.413, 1.109)

The exponentiated coefficients are correct but CI is wrong

For the 2nd code:

#           Ideal   Int 
#Model1 
#            (1)            (2) 
#ETI    -0.793***   -0.273  
#(0.273, 0.749)       (0.538, 1.078)

The CI is correct and matches with cofint

For the 3rd code:

#       Ideal   Int 
#      Model1   
#       (1) (2) 
#ETI    0.453*  0.761***    
#(0.950, 2.602) (1.512, 3.033)

The CI is wrong, I think it is doubly exponentiating

Ben
  • 28,684
  • 5
  • 23
  • 45
Saba
  • 21
  • 1
  • 1. negative CIs need not necessarily be wrong. 2. I'd rather use `texreg` instead of stargazer. 3. If you want to stick with stargazer, I'd try to work on the CIs on the summary(lm(x))-level instead of trying to change them using stargazer. – tester Feb 23 '21 at 20:56

2 Answers2

1

If texreg is also ok for you, here's an example how to run exp on the CIs and use them for the regression table. Since you didn't include data, I used birthwt.

library(MASS)
library(nnet)
library(stargazer)
example(birthwt)

test1 <- multinom(race ~ age + lwt + bwt,
                  data = birthwt)
summary(test1)
summary(test1)["standard.errors"]

ci.low <- c(confint(test1)[1:4], confint(test1)[9:12])
ci.up <-  c(confint(test1)[5:8], confint(test1)[13:16])
texreg::screenreg(test1,
                  ci.force = T,
                  override.ci.low = exp(ci.low),
                  override.ci.up = exp(ci.up)
                  )
tester
  • 1,662
  • 1
  • 10
  • 16
1

One alternative is to use the gtsummary package this will allow you to easily exponentiate models in one line of code. You have to factor race to make it work.

library(nnet)
library(MASS)
library(gtsummary)

test1 <- multinom(factor(race) ~ age + lwt + bwt,
                  data = birthwt) %>% 
  tbl_regression( exponentiate = TRUE)


test2 <- multinom(factor(race) ~ age + lwt + bwt,
                  data = birthwt)%>% 
  tbl_regression( exponentiate = TRUE)
Mike
  • 3,797
  • 1
  • 11
  • 30