Estimate negative binomial dispersion parameter $k$ using mean and proportion of zeros I came across supplemental methods of a paper estimating the mean ($R$) and dispersion ($k$) of a negative binomial distribution that stated:

Page 8: "Given estimates of the mean ($\hat{R}$) and proportion of zeros ($\hat{p_0}$) of a negative binomial distribution, the parameter $k$ can be estimated by solving the equation $\hat{p_0} = (1+\frac{\hat{R}}{k})^{-k}$ numerically."

This "zero-class estimator" approach is also used here.
I would like to compare the accuracy of this method (with regards to inference of $k$) with my results using MLE. This initially seemed simple, but I have been unable to successfully estimate $k$ using this approach in R programming. I tried solving for $k$ algebraically but my algebra may be wrong (happy to post if requested, but omitting equations for readability/brevity).
Any advice on how to use this approach to estimate $k$ (in R or other statistical software) would be much appreciated.

Given that both $\hat{p}_0$ and $(1+\frac{\hat{R}}{k})^{-k}$ are by definition non-negative, you can just minimize $(\hat{p}_0 - (1+\frac{\hat{R}}{k})^{-k})^2$. Almost any software will have some generic minimization tools (e.g. ucminf in R). The only difficulty will be the scenarios where the estimate of the dispersion parameter should be 0 or $\infty$ (depending on your parametrization), which is a genuine potential issue.
