here mwe:
library(pscl) data("biochemists", package = "pscl") fm_pois <- glm(art ~ ., data = biochemists, family = poisson) fm_qpois <- glm(art ~ ., data = biochemists, family = quasipoisson) fm_nb <- glm.nb(art ~ ., data = biochemists) fm_zinb <- zeroinfl(art ~ . | 1, data = biochemists, dist = "negbin") library(stargazer) stargazer( fm_pois, fm_qpois, fm_nb, fm_zinb , type = "text" ) ============================================================================= dependent variable: ----------------------------------------------------------- art poisson glm: quasipoisson negative zero-inflated link = log binomial count data (1) (2) (3) (4) ----------------------------------------------------------------------------- femwomen -0.225*** -0.225*** -0.216*** -0.216*** (0.055) (0.074) (0.073) (0.073) marmarried 0.155** 0.155* 0.150* 0.150* (0.061) (0.083) (0.082) (0.082) kid5 -0.185*** -0.185*** -0.176*** -0.176*** (0.040) (0.054) (0.053) (0.053) phd 0.013 0.013 0.015 0.015 (0.026) (0.036) (0.036) (0.036) ment 0.026*** 0.026*** 0.029*** 0.029*** (0.002) (0.003) (0.003) (0.003) constant 0.305*** 0.305** 0.256* 0.256* (0.103) (0.139) (0.137) (0.139) ----------------------------------------------------------------------------- observations 915 915 915 915 log likelihood -1,651.056 -1,561.958 -1,560.959 theta 2.264*** (0.271) akaike inf. crit. 3,314.113 3,135.917 ============================================================================= note: *p<0.1; **p<0.05; ***p<0.01 i'm looking multicolumn output this:
============================================================================= dependent variable: ----------------------------------------------------------- art poisson negative binomial poisson quasipoisson nb zinb (1) (2) (3) (4) ----------------------------------------------------------------------------- femwomen -0.225*** -0.225*** -0.216*** -0.216*** (0.055) (0.074) (0.073) (0.073) marmarried 0.155** 0.155* 0.150* 0.150* (0.061) (0.083) (0.082) (0.082) kid5 -0.185*** -0.185*** -0.176*** -0.176*** (0.040) (0.054) (0.053) (0.053) phd 0.013 0.013 0.015 0.015 (0.026) (0.036) (0.036) (0.036) ment 0.026*** 0.026*** 0.029*** 0.029*** (0.002) (0.003) (0.003) (0.003) constant 0.305*** 0.305** 0.256* 0.256* (0.103) (0.139) (0.137) (0.139) ----------------------------------------------------------------------------- observations 915 915 915 915 log likelihood -1,651.056 -1,561.958 -1,560.959 theta 2.264*** (0.271) akaike inf. crit. 3,314.113 3,135.917 ============================================================================= note: *p<0.1; **p<0.05; ***p<0.01 - first row should have word
poissonfirst 2 columns ,negative binomialnext 2 columns. - second row should have columns names
poisson,quasi poisson,negative binomial,zero inflated negative binomial.
i found link not figured out how one. highly appreciated. thanks
like nick kennedy not think stargazer can produce desired output directly.
therefore, here workaround: save stargazer table in object , add desired lines manually. hardcoded here; more effort should possible center text above respective columns automatically. note changed stargazer call in order hide (wrong) model names.
library(pscl) library(stargazer) data("biochemists", package = "pscl") fm_pois <- glm(art ~ ., data = biochemists, family = poisson) fm_qpois <- glm(art ~ ., data = biochemists, family = quasipoisson) fm_nb <- glm.nb(art ~ ., data = biochemists) fm_zinb <- zeroinfl(art ~ . | 1, data = biochemists, dist = "negbin") byline <- do.call("c", strsplit( capture.output( stargazer(fm_pois, fm_qpois, fm_nb, fm_zinb, type = "text", model.names = false) ), "\n")) result <- append( byline, c( " poisson negative binomial", "", " poisson quasipoisson nb zinb" ), after = c(4, 5, 6)) cat(paste(result, collapse = "\n")) # ================================================================== # dependent variable: # ------------------------------------------------ # art # poisson negative binomial # # poisson quasipoisson nb zinb # (1) (2) (3) (4) # ------------------------------------------------------------------ # femwomen -0.225*** -0.225*** -0.216*** -0.216*** # (0.055) (0.074) (0.073) (0.073) # # marmarried 0.155** 0.155* 0.150* 0.150* # (0.061) (0.083) (0.082) (0.082) # # kid5 -0.185*** -0.185*** -0.176*** -0.176*** # (0.040) (0.054) (0.053) (0.053) # # phd 0.013 0.013 0.015 0.015 # (0.026) (0.036) (0.036) (0.036) # # ment 0.026*** 0.026*** 0.029*** 0.029*** # (0.002) (0.003) (0.003) (0.003) # # constant 0.305*** 0.305** 0.256* 0.256* # (0.103) (0.139) (0.137) (0.139) # # ------------------------------------------------------------------ # observations 915 915 915 915 # log likelihood -1,651.056 -1,561.958 -1,560.959 # theta 2.264*** (0.271) # akaike inf. crit. 3,314.113 3,135.917 # ================================================================== # note: *p<0.1; **p<0.05; ***p<0.01
Comments
Post a Comment