Another user asked How do I add confidence intervals to odds ratios in stargazer table? and outlined their solution to the problem (I've included the relevant lines of code here)
OR.vector <- exp(mylogit$coef)
CI.vector <- exp(confint(mylogit))
p.values <- summary(mylogit)$coefficients[, 4]
# Table with ORs and CIs`
stargazer(mylogit, coef = list(OR.vector), ci = T,
ci.custom = list(CI.vector), p = list(p.values),
single.row = T, type = "text")
When I try to run the same code for my own model, I receive the following error
Error in summary(ml.TatC)$coefficients[, 4] :
incorrect number of dimensions
Might anyone know why this is happening? Thank you in advance for your help!
UPDATE: Here is a link to the .txt file used.
The code I have used is as follows:
tattoo <- read.table("https://ndownloader.figshare.com/files/6920972",
header=TRUE, na.strings=c("unk", "NA"))
library(mlogit)
Tat<-mlogit.data(tattoo, varying=NULL, shape="wide", choice="size", id.var="date")
ml.Tat<-mlogit(size~1|age+sex+yy, Tat, reflevel="small", id.var="date")
library(stargazer)
OR.vector<-exp(ml.Tat$coef)
CI.vector<-exp(confint(ml.Tat))
p.values<-summary(ml.Tat)$coefficients[,4] #incorrect # of dimensions, how am I supposed to determine dimensions?
stargazer(ml.Tat, coef=list(OR.vector), ci=TRUE, ci.custom=list(CI.vector), single.row=T, type="text", star.cutoffs=c(0.05,0.01,0.001), out="table1.txt", digits=4)