# Can I estimate Variance of Gamma from Negative Binomial distributed data, given NB is Poisson-Gamma mixture

I believe the data I have follows Negative Binomial distribution (over-dispersed Poisson). We know Negative Binomial is a mixture of Poisson and Gamma. The variance of this Gamma distribution is actually the variance I am interested in. Can I estimate the variance of the Gamma distribution of the mixture from just my Negative Binomial data.

if $X|\lambda \sim Poisson (\lambda)$

$\lambda \sim Gamma(shape = r, scale = p/(1 − p))$

then, the marginal distribution of X follows $NB(r,p)$,

$var(X) = \frac{pr}{(1-p)^2}$

$E(X) = \frac{pr}{1-p}$

$var(\lambda) = r \cdot \frac{p}{1-p}$

Hence, $var(\lambda) = var(X) - E(X) = \frac{pr}{(1-p)^2} - \frac{pr}{1-p} = \frac{rp}{1-p}$

Also, we can consider X and $\lambda$ are two random variables, then

$Var(X) = E(Var(X|\lambda))+ Var(E(X|\lambda))$

$Var(X) = E(\lambda)+ Var(\lambda)$

$Var(\lambda) = Var(X) - E(\lambda)$

$E(X) = E(E(X|\lambda)) = E(\lambda)$

From the derivations, it seems like I can estimate the variance of Gamma distribution in the mixture by var(X)-E(X).

Alternatively, if we parameterize Negative Binomial X using $\mu$ and size, the $var(X) = \mu + \mu^2/size$. So $var(\lambda) = \mu^2/size$.

-