When I'm adding custom confidence intervals with "ci.custom" in "stargazer" for one variable model, R returns: "Error in if (ncol(ci.custom[[i]]) != 2) { : argument is of length zero". When I do the same, but with several independent variables, everything works perfectly.
(1) ologit model:
m <- polr(Risk_Taking_QNT ~ Wealth_log, data=F, Hess=T)
(2) confidence intervals:
cim <- exp(confint(m))
I get:
2.5 % 97.5 %
1.006 1.223
(3) making output table:
stargazer(m, ci.custom = list(cim), ci = T, ci.level = 0.95, ci.separator = ";", apply.coef=exp, t.auto=FALSE, p.auto=FALSE, type="text")
R returns: "Error in if (ncol(ci.custom[[i]]) != 2) { : argument is of length zero"
========================================================================
Same steps with 2-variable model:
(1) m <- polr(Risk_Taking_QNT ~ Wealth_log + Experience, data=F, Hess=T)
(2) cim <- exp(confint(m))
I get:
2.5 % 97.5 %
Wealth_log 0.8768112 1.081713
Experience 1.2705479 1.530633
(3) stargazer(m, ci.custom = list(cim), ci = T, ci.level = 0.95, ci.separator = ";", apply.coef=exp, t.auto=FALSE, p.auto=FALSE, type="text")
I get a normal table with correct coefficients and intervals. I've tried different variables and result is always the same: works only for 2+ variables.
Thank you all for any help!
======================================================================================================================================================
Here is the reproducible example:
library(MASS)
library(stargazer)
Data
Y <- as.factor(c(3, 4, 4, 2, 1, 4, 3, 4, 3, 1))
X1 <- c(8.8, 6.2, 7.3, 7.3, 7.2, 6.4, 7.1, 5.5, 5.7, 7.2)
X2 <- c(7, 8, 9, 8, 8, 10, 9, 9, 7, 6)
Model with 1 variable where I get error
m1 <- polr(Y ~ X1, Hess=T)
cim1 <- exp(confint(m1))
stargazer(m1, ci.custom = list(cim1), ci = T, ci.level = 0.95, ci.separator = ";", apply.coef=exp, t.auto=FALSE, p.auto=FALSE, type="text")
Model with 2 variables which works fine
m2 <- polr(Y ~ X1 + X2, Hess=T)
cim2 <- exp(confint(m2))
stargazer(m2, ci.custom = list(cim2), ci = T, ci.level = 0.95, ci.separator = ";", apply.coef=exp, t.auto=FALSE, p.auto=FALSE, type="text")