Description Usage Arguments Details Value Author(s) References Examples

This function performs the estimation of the beta-binomial distribution parameters, *p* and *φ*, by the method of moments. The variance of the estimations is performed using maximum likelihood by the analytically determined by a beta-binomial density function.

1 | ```
BBest(y,n)
``` |

`y` |
the outcome variable that is supposed to be distributed as a beta-binomial distribution. |

`n` |
the maximum score of the beta-binomial trials. |

The method of moments assumes that the response variable *y* follows a beta-binomial distribution and using the moments of first and second order, i.e., the mean and expectation of the beta-binomial distribution gets the estimation of the parameters.

*E[y]=np*

*Var[y]=np(1-p)[1+(n-1)φ/(1+φ)]*

The dispersion parameter, *φ*, of the beta-binomial distribution can only be positive, as the beta-binomial distribution models the overdispersion. So if the estimated *φ* parameter by the method of moments is negative, meaning that there exists underdispersion, the beta-binomial model will not be useful and the function will print an error message, suggesting the use of the binomial distribution.

The variance of the estimations is calculated by maximum likelihood by the second derivative of the density function of the beta-binomial distribution, using the Fisher score matrix, and replace it by the estimated values.

The function `summary`

(i.e., `summary.BBest`

) can be used to obtain or print a summary of the results.

`n` |
the maximum score of the Binomial trials. |

`p` |
the estimated probability parameter. |

`phi` |
the estimated dispersion parameter. |

`vcov` |
the variance and covariance matrix of the parameters of the beta-binomial distribution |

Josu Najera

Dae-Jin Lee

Arostegui I., Nuñez-Antón V. & Quintana J. M. (2006): Analysis of short-form-36 (SF-36): The
beta-binomial distribution approach, *Statistics in Medicine*, 26, 1318-1342.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ```
# We simulate beta-binomial distributed observations.
n <- 10 # maximum score of the Binomial trials
k <- 1000 # number of simulated observations
p <- 0.7 # probability parameter of the beta-binomial distribution
phi <- 1.6 # dispersion parameter of the beta-binomial distribution
set.seed(5)
y <- rBB(k,n,p,phi)
# Estimation
est <- BBest(y,n)
print(est)
# Summary of the results
summary(est)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.