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 |
par0 |
Optional starting values for the iterative estimation procedure.
A vector with entries |
maxit |
Integer scalar. The maximum number of iterations to be undertaken
by |
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 |
useGinv |
Logical scalar. Should the |
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:
-
"size"
The value of thesize
argument. -
"log.like"
The (maximised) value of the log likelihood of the data. -
"covMat"
An estimate of the (2 \times 2
) covariance matrix of the parameter estimates. This is formed as the inverse of the hessian (of the negative log likelihood) calculated byaHess()
. -
ndata
The number of non-missing values in the data set for which the likelihood was maximised, i.e.sum(!is.na(x))
.
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.