What r parameter is used in a negative binomial regression? From my understanding of the negative binomial regression, we have $Y_i|X_i; \theta$ is distributed $Neg Binom (r_i, p_i)$, where $r_i$ is known and fixed (analogous to a fixed $\sigma^2$ when we assume the distribution is normal) and $p_i$ is estimated through maximum liklihood. 
After writing the pdf of the negative binomial in terms of the exponential family, I get $\eta = log(p) = \theta^T*x$
To get the predicted value of $Y_i, \hat{Y_i} = E[Y_i|X_i; \theta^\star] = p_i^\star*r_i/(1 - p_i^\star) = r_i/(p_i^{-1} - 1) = r_i/(e^{-\eta_i} - 1) = r_i/(e^{- \theta^{T^\star*x_i}} - 1) $
My question is the following: What is the $r_i$ that we assume? 
 A: As a "standard" approach to count data we use Poisson regression. This approach can however be problematic because, if you recall, Poisson distribution assumes mean = variance = $\lambda$ and this is often not the case for real-life data. When variance is greater then mean for Poisson regression we are dealing with overdispersion. In such case you need to use models that are robust to overdispersion, with quasi-Poisson and negative binomial being the most common alternatives.
General formulation of negative binomial probability mass function is
$$ f(x) = \binom{x+r-1}{x} p^x(1-p)^r $$
where $r>0$ is number of failures until the experiment is stopped and $p$ is probability of success in single trial.
In GLM's case, this function needs to be re-parametrized. We define GLM's using linear predictor $\eta = \mathbf{X\beta}$ and link function $g$ such that $E(Y) = \mu = g^{−1}(\eta)$, so we need the distribution to be defined in terms of mean. This leads to parametrization as following
$$ f(x) = \left(\frac{r}{r+m}\right)^r \frac{\Gamma(r+x)}{x! \, \Gamma(r)} \left(\frac{m}{r+m}\right)^x $$
with mean $m$ and variance $m + m^2/r$. In such case $r$ is a dispersion (or shape) parameter that deals with overdispersion. You can find some more information about dispersion parameter in this thread and here precisely about dispersion parameter for negative binomial regression.
So it is a parameter of negative binomial distribution that describes it's shape. It does not have any direct interpretation (as in $r$ case of standard parametrization of negative binomial distribution) and it is not something that we assume, but rather something that we also estimate from the data.
Check also the following references:
Nelder, J. & Wedderburn, R. (1972). Generalized Linear Models. Journal of the Royal Statistical Society. Series A (General) (Blackwell Publishing) 135 (3): 370–384. 
Hinde, J., & Demétrio, C. G. (1998). Overdispersion: models and estimation. Computational Statistics & Data Analysis, 27(2), 151-170.
Allison, P. D., & Waterman, R. P. (2002). Fixed–effects negative binomial regression models. Sociological methodology, 32(1), 247-265.
Berk, R., & MacDonald, J. M. (2008). Overdispersion and Poisson regression. Journal of Quantitative Criminology, 24(3), 269-284.
Rodrigues, G. (November 6, 2013). Models for Count Data With Overdispersion.
