Open xiang526 opened 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.
nb_model = smf.glm(formula, data=reg_df, family = sm.families.NegativeBinomial(alpha=alpha)).fit()
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.
nb_model = smf.negativebinomial(formula, data=reg_df).fit()
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.
Is there python code for Negative Binomial Regression and Hierarchical Negative Binomial Regression?