You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Prentice, R. L. 1986. “Binary Regression Using an Extended Beta-Binomial Distribution, With Discussion of Correlation Induced by Covariate Measurement Errors.” Journal of the American Statistical Association 81 (394): 321–27. doi:10.2307/2289219.
This shows that Beta-Binomial can be extended to negative correlation and under dispersion. It's still a proper distribution without the beta-binomial restriction. It also means that no excess dispersion is in the interior of the parameter space and score test for binomial versus extended beta-binomial, i.e. under or over dispersion, is in the interior of the parameter space.
Williams, D. A. 1982. “Extra-Binomial Variation in Logistic Linear Models.” Journal of the Royal Statistical Society. Series C (Applied Statistics) 31 (2): 144–48. doi:10.2307/2347977.
This is using quasi-likelihood with variance functions from beta-binomial and normal random effects model. However, both are fully specified models.
Also, estimation works by iterating with pre-specified weights and updating dispersion parameter using pearson statistic, which we will have in GLM with #3410
Note: beta-binomial model has a dispersion that varies with the count (number of trials). If there is no differential "exposure", then it reduces to GLM type dispersion (constant factor with standard variance function).
Hardin, J. W., and J. M. Hilbe. 2014. “Estimation and Testing of Binomial and Beta-Binomial Regression Models with and without Zero Inflation.” Stata Journal 14 (2): 292–303.
Based on a quick literature search I didn't find much on formulas for score, hessian for beta-binomial.
Palm et al 2021 article has score functions using digamma function. and hessian based on trigamma function. (I didn't look closely at it.)
The likelihood function can be expressed in terms of special Beta function or Gamma function. I don't know if there is a special function for derivatives of Beta function.
Palm et al don't use the same definition of the dispersion parameter
theirs is alpha + beta
the "usual" GLM is 1 / (alpha + beta + 1)
note, Beta "prior", mixing distribution becomes a degenerate 1-point distribution (no heterogeneity) if alpha + beta -> inf
GLM dispersion -> 0 to approach Binomial without mixing
The Stata article Hardin and Hilbe seems to have a typo
It says dispersion parameter sigma = 1 / (alpha * beta), but AFAICS, it should be sigma = 1 / (alpha + beta) which would then be just the reciprocal of Palm et al.
The main point is that I cannot just copy formulas for score and hessian if parameterization differs
Cepeda-Cuervo, Edilberto, and María Victoria Cifuentes-Amado. "Double generalized beta-binomial and negative binomial regression models." Revista Colombiana de Estadística 40, no. 1 (2017): 141-163.
includes a link function for the dispersion parameter, similar to betareg.BetaModel, and WIP dispersion models #7778
Parameterization across articles is confusing and I don't have an overview anymore. I went through this already once.
For "foreign" variance function for GLM-Binomial #1777, we have several options that don't all map into Beta-Binomial.
For Beta-Binomial itself the main issue is what is used as "dispersion" parameter, and how that maps to a, b of the Beta mixing distribution.
d1 = a + b: simplest
basic form of variance function
V(y) = [n * p * (1 - p)] * [1 + d * (n_i - 1)]
If all n_i are the same then theta = scale = [1 + d * (n_trials - 1)].
If all n_i=1, then there is no excess dispersion, i.e. reduces to Bernoulli.
The V(y) function is also in this way in Simonoff 2003 Analyzing Categorical Data book p. 400, and p. 94
(theta in Simonoff) d = 1 / (a + b + 1)
Note: a+b+1 >= 1 (from Beta distribution a>0, b>0
d in [0, 1]
e.g. Logit link for d
Hinde 2013 working paper Beta Binomial Regression uses sigma where d = sigma / (1 + sigma)
then, sigma = d / (1 - d) in (0, inf)
log-link for sigma
in original Beta-Binomial parameterization (Hinde 2013, Wikipedia)
E(y) = n * a / ( a + b)
v(y) = n * a * b * (a + b + n) / [ ( a + b)**2 * (a + b + 1)]
= n * [a / ( a + b)] * [b / ( a + b)] * [ (a + b + n) / (a + b + 1)]
= n p * (1 - p) * (d1 + n) / (d1 + 1)
overdispersion is [ (a + b + n) / (a + b + 1)]
still need parameters when Beta-Binomial reduces to Binomial
V_B(y) = n p * (1 - p)
need d->0 for V_BB -> V_B
or sigma -> 0
does this mean d1 -> inf ? (sounds correct, Beta collapses to a single point, variance of Beta -> 0, i.e. no heterogeneity)
check references for overdispersion tests.
now, we still need loglike in parameterization, d1, d and sigma.
...
update
d1 = 1 / sigma d1 is precision (as in Beta distribution), s is scale
follows from last equality in
d = 1 / (a + b + 1) = 1 / (d1 + 1) == s / (s + 1)
also overdispersion:
(d1 + n) / (d1 + 1) = (d1 + 1 + n - 1) / (d1 + 1) = 1 + (n - 1) / (d1 + 1) = 1 + (n - 1) * d
where d = 1 / (d1 + 1)
We can use var_weights in GLM to adjust the variance function because n_trials is known, and d or sigma can be estimated on the outside.
I'm not sure how much bse, cov_params will differ if we don't take estimated d or sigma into account.
I guess, we stll need to use HC cov_type.
Cepeda-Cuervo, Edilberto, and María Victoria Cifuentes-Amado. "Double generalized beta-binomial and negative binomial regression models." Revista Colombiana de Estadística 40, no. 1 (2017): 141-163.
also uses d1: phi = a + b
based on BetaRegression parameterization.
They use logit-link for mu and log link for phi
1st and second derivatives are analytical formulas and derivative_factors, e.g. equs (23)-(27) (*) for general expression of xxx_factors.
(needs digamma and trigamma functions)
(*) we might be able to use this for generic code. chain rule similar to derivative factors in glm.
Hi, this looks promising. We have loads of over-dispersed count data and are currently using corncob in R to model it with a beta-binomial. I'm interested to continue investigating how its working for our data across spectrum of datasets. If it helps you, here are the links to the paper and package. We'd be interested to help you test, though not sure I can be much help in implementing.
The implementation right now is mostly generic based on #7793
For the specific case, we need unit tests and, if possible, analytical derivatives for better numerical performance.
I'm currently working on post-estimation results, like get_prediction, get_influence, get_diagnostic. Those are mostly not available for multilink models yet, but should become available before the next release.
Activity
josef-pkt commentedon Apr 14, 2017
Prentice, R. L. 1986. “Binary Regression Using an Extended Beta-Binomial Distribution, With Discussion of Correlation Induced by Covariate Measurement Errors.” Journal of the American Statistical Association 81 (394): 321–27. doi:10.2307/2289219.
This shows that Beta-Binomial can be extended to negative correlation and under dispersion. It's still a proper distribution without the beta-binomial restriction. It also means that no excess dispersion is in the interior of the parameter space and score test for binomial versus extended beta-binomial, i.e. under or over dispersion, is in the interior of the parameter space.
Williams, D. A. 1982. “Extra-Binomial Variation in Logistic Linear Models.” Journal of the Royal Statistical Society. Series C (Applied Statistics) 31 (2): 144–48. doi:10.2307/2347977.
This is using quasi-likelihood with variance functions from beta-binomial and normal random effects model. However, both are fully specified models.
Also, estimation works by iterating with pre-specified weights and updating dispersion parameter using pearson statistic, which we will have in GLM with #3410
Note: beta-binomial model has a dispersion that varies with the count (number of trials). If there is no differential "exposure", then it reduces to GLM type dispersion (constant factor with standard variance function).
josef-pkt commentedon Jan 14, 2020
random find
aod: Analysis of Overdispersed Datahttps://cran.r-project.org/web/packages/aod/index.html
R package that includes beta-binomial regression (MLE)
josef-pkt commentedon Nov 7, 2020
In Stata, including zero inflated versions
Hardin, J. W., and J. M. Hilbe. 2014. “Estimation and Testing of Binomial and Beta-Binomial Regression Models with and without Zero Inflation.” Stata Journal 14 (2): 292–303.
josef-pkt commentedon Nov 21, 2020
Based on a quick literature search I didn't find much on formulas for score, hessian for beta-binomial.
Palm et al 2021 article has score functions using digamma function. and hessian based on trigamma function. (I didn't look closely at it.)
The likelihood function can be expressed in terms of special Beta function or Gamma function. I don't know if there is a special function for derivatives of Beta function.
Palm, Bruna G., Fábio M. Bayer, and Renato J. Cintra. 2021. “Signal Detection and Inference Based on the Beta Binomial Autoregressive Moving Average Model.” Digital Signal Processing 109 (February): 102911. https://doi.org/10.1016/j.dsp.2020.102911.
(published in the future)
josef-pkt commentedon Nov 23, 2020
a bit painful
Palm et al don't use the same definition of the dispersion parameter
theirs is
alpha + betathe "usual" GLM is
1 / (alpha + beta + 1)note, Beta "prior", mixing distribution becomes a degenerate 1-point distribution (no heterogeneity) if
alpha + beta -> infGLM dispersion -> 0 to approach Binomial without mixing
The Stata article Hardin and Hilbe seems to have a typo
It says dispersion parameter
sigma = 1 / (alpha * beta), but AFAICS, it should besigma = 1 / (alpha + beta)which would then be just the reciprocal of Palm et al.The main point is that I cannot just copy formulas for score and hessian if parameterization differs
josef-pkt commentedon Oct 5, 2021
Cepeda-Cuervo, Edilberto, and María Victoria Cifuentes-Amado. "Double generalized beta-binomial and negative binomial regression models." Revista Colombiana de Estadística 40, no. 1 (2017): 141-163.
includes a link function for the dispersion parameter, similar to betareg.BetaModel, and WIP dispersion models #7778
derivatives, score and hessian in appendix
they define loglike in terms of Beta functions,
scipy has betaln
related derivatives of beta function
https://brilliant.org/wiki/beta-function/#derivative-of-the-beta-function
https://math.stackexchange.com/questions/1464499/how-to-find-the-derivative-of-the-beta-function
josef-pkt commentedon Oct 6, 2021
I need code with different parameterizations.
Parameterization across articles is confusing and I don't have an overview anymore. I went through this already once.
For "foreign" variance function for GLM-Binomial #1777, we have several options that don't all map into Beta-Binomial.
For Beta-Binomial itself the main issue is what is used as "dispersion" parameter, and how that maps to a, b of the Beta mixing distribution.
basic form of variance function
V(y) = [n * p * (1 - p)] * [1 + d * (n_i - 1)]
If all n_i are the same then theta = scale = [1 + d * (n_trials - 1)].
If all n_i=1, then there is no excess dispersion, i.e. reduces to Bernoulli.
The V(y) function is also in this way in Simonoff 2003 Analyzing Categorical Data book p. 400, and p. 94
(theta in Simonoff) d = 1 / (a + b + 1)
Note: a+b+1 >= 1 (from Beta distribution a>0, b>0
d in [0, 1]
e.g. Logit link for d
Hinde 2013 working paper Beta Binomial Regression uses sigma where
d = sigma / (1 + sigma)then, sigma = d / (1 - d) in (0, inf)
log-link for sigma
in original Beta-Binomial parameterization (Hinde 2013, Wikipedia)
E(y) = n * a / ( a + b)
v(y) = n * a * b * (a + b + n) / [ ( a + b)**2 * (a + b + 1)]
= n * [a / ( a + b)] * [b / ( a + b)] * [ (a + b + n) / (a + b + 1)]
= n p * (1 - p) * (d1 + n) / (d1 + 1)
overdispersion is
[ (a + b + n) / (a + b + 1)]still need parameters when Beta-Binomial reduces to Binomial
V_B(y) = n p * (1 - p)
need d->0 for V_BB -> V_B
or sigma -> 0
does this mean d1 -> inf ? (sounds correct, Beta collapses to a single point, variance of Beta -> 0, i.e. no heterogeneity)
check references for overdispersion tests.
now, we still need loglike in parameterization, d1, d and sigma.
...
update
d1 = 1 / sigma d1 is precision (as in Beta distribution), s is scale
follows from last equality in
d = 1 / (a + b + 1) = 1 / (d1 + 1) == s / (s + 1)
also overdispersion:
(d1 + n) / (d1 + 1) = (d1 + 1 + n - 1) / (d1 + 1) = 1 + (n - 1) / (d1 + 1) = 1 + (n - 1) * d
where d = 1 / (d1 + 1)
josef-pkt commentedon Oct 6, 2021
We can use var_weights in GLM to adjust the variance function because n_trials is known, and d or sigma can be estimated on the outside.
I'm not sure how much bse, cov_params will differ if we don't take estimated d or sigma into account.
I guess, we stll need to use HC cov_type.
josef-pkt commentedon Oct 6, 2021
Cepeda-Cuervo, Edilberto, and María Victoria Cifuentes-Amado. "Double generalized beta-binomial and negative binomial regression models." Revista Colombiana de Estadística 40, no. 1 (2017): 141-163.
also uses d1: phi = a + b
based on BetaRegression parameterization.
They use logit-link for mu and log link for phi
1st and second derivatives are analytical formulas and derivative_factors, e.g. equs (23)-(27) (*) for general expression of xxx_factors.
(needs digamma and trigamma functions)
(*) we might be able to use this for generic code. chain rule similar to derivative factors in glm.
josef-pkt commentedon Oct 7, 2021
here's the code 4 parameterization, scipy/standard and 3 with mean + precision/scale/dispersion
agartland commentedon Nov 11, 2021
Hi, this looks promising. We have loads of over-dispersed count data and are currently using
corncobin R to model it with a beta-binomial. I'm interested to continue investigating how its working for our data across spectrum of datasets. If it helps you, here are the links to the paper and package. We'd be interested to help you test, though not sure I can be much help in implementing.https://cran.r-project.org/web/packages/corncob/corncob.pdf
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7514055/
josef-pkt commentedon Nov 11, 2021
Thanks for the comment and references.
The implementation right now is mostly generic based on #7793
For the specific case, we need unit tests and, if possible, analytical derivatives for better numerical performance.
I'm currently working on post-estimation results, like get_prediction, get_influence, get_diagnostic. Those are mostly not available for multilink models yet, but should become available before the next release.