yflyzhang / spatial_COVID_19

Data and code release for "The spatial dissemination of COVID-19 and associated socio-economic consequences"
MIT License
3 stars 1 forks source link

help #1

Open xiang526 opened 2 years ago

xiang526 commented 2 years ago

Is there python code for Negative Binomial Regression and Hierarchical Negative Binomial Regression?

yflyzhang commented 2 years ago

Thanks for your interest.

(1.1). In Figure2-Spatial analysis by R.ipynb, we present regression analysis using R.

(1.2). In Figure2-Spatial analysis and plot.ipynb, we also present some regression analyses using Python. See section 2. Regression Analysis -> Negative Binomial Regression there for further details. Specifically, we use the Python package statsmodels to replicate the results obtained from R analysis.

to do the analysis, but the problem is that the above line needs a parameter named alpha to be specified before the execution. The parameter alpha can be obtained from R analysis, so in this way, you cannot avoid using R.

which doesn't need a prior parameter to be specified.

But generally speaking, R has more powerful statistical tools than Python. Please take R as the first choice in this scenario.


(2). Hierarchical Negative Binomial Regression can be obtained by running several separate Negative Binomial Regression. Some packages in R (such as texreg) provide an easy way to combine the regression results in a table. I am not sure is there any Python package addressing this, but I think we can simply do several separate analyses and manually combine the results together in a table.

Hope the above explanation will be helpful.