mleBb {dbd}R Documentation

Maximum likelihood estimation of the parameters of a beta binomial distribution.

Description

Calculates maximum likelihood estimates of the m and s parameters of a beta binomial distribution. Calls upon optim() with the "L-BFGS-B" method.

Usage

    mleBb(x, size, par0, maxit=1000, covmat=TRUE, useGinv=FALSE)

Arguments

x

Integer vector of counts to which a beta binomial distribution is to be fitted. Missing values are allowed. (These are discarded before the data are analysed.)

size

Integer scalar specifying the upper limit of the “support” of the beta binomial distribution under consideration. The support is the set of integers {0, 1, ..., size}. (The values of x may sometimes be considered to be the number of “successes” in size trials.

par0

Optional starting values for the iterative estimation procedure. A vector with entries m and s. Ideally this vector should be named; if not it is assumed that the entries are in the order m, s. If not supplied starting values are calculated using meBb().

maxit

Integer scalar. The maximum number of iterations to be undertaken by optim(). What happens if this number is exceeded depends on the value of options()[["maxitErrorOrWarning"]]. This may be "error" (in which case an error is thrown if maxit is exceeded) or "warning" (in which case a warning is issued). The values is set equal to "error" at startup. It may be switched, from on possibility to the other, by means of the function set.eow().

covmat

Logical scalar. Should the covariance matrix of the parameter estimates be calculated? In simulation studies, in which the covariance matrix is not of interest, calculations might be speeded up a bit by setting covmat=FALSE.

useGinv

Logical scalar. Should the ginv() (generalised inverse) function from the MASS package be used to calculate a surrogate covariance matrix if the hessian is numerically singular? This is probably not advisable; the possibility of using the generalised inverse is provided for the sake of completeness. Caveat utilitor. This argument is ignored if covmat is FALSE.

Details

This function is provided so as to give a convenient means of comparing the fit of a beta binomial distribution with that of the discretised Beta (db) distribution which is the focus of this package.

Value

An object of class "mleBb" which is a vector of length two. Its first entry m is the estimate of the (so-called) success probability m; its second entry s is the estimate of the overdispersion parameter s. It has a number of attributes:

Author(s)

Rolf Turner r.turner@auckland.ac.nz

References

Bruce Swihart and Jim Lindsey (2020). rmutil: Utilities for Nonlinear Regression and Repeated Measurements Models. R package version 1.1.4. https://CRAN.R-project.org/package=rmutil

Wikipedia, https://en.wikipedia.org/wiki/Beta-binomial_distribution

See Also

mleDb() optim() aHess() vcov.mleBb() hrsRcePred visRecog

Examples

if(require(hmm.discnp)) {
   X <- hmm.discnp::Downloads
   f <- mleBb(X,15)
}
set.seed(42)
X <- c(rbinom(20,10,0.3),rbinom(20,10,0.7))
f <- mleBb(X,10)
g <- mleDb(X,10,TRUE)
print(attr(f,"log.like"))
print(attr(g,"log.like")) # Not much difference.
dbfit5  <- with(visRecog,mleDb(tot5,20,TRUE))
print(vcov(dbfit5))
# See the help for data sets "hrsRcePred" and "visRecog" for
# other examples.

[Package dbd version 0.0-22 Index]