| Bernoulli {lite} | R Documentation |
Frequentist inference for the Bernoulli distribution
Description
Functions involved in making inferences about the probability of success in a Bernoulli distribution using maximum likelihood estimation.
Usage
fitBernoulli(data)
## S3 method for class 'Bernoulli'
coef(object, ...)
## S3 method for class 'Bernoulli'
vcov(object, ...)
## S3 method for class 'Bernoulli'
nobs(object, ...)
## S3 method for class 'Bernoulli'
logLik(object, ...)
Arguments
data |
A numeric vector of outcomes from Bernoulli trials: 0 for a
failure, 1 for a success. Alternatively, a logical vector with FALSE
for a failure and TRUE for a success. Missing values are removed using
|
object |
A fitted model object returned from |
... |
Further arguments. None are used currently. |
Details
fitBernoulli: fit a Bernoulli distribution using maximum likelihood
estimation, using an independence log-likelihood formed by
summing contributions from individual observations. No adjustment for
cluster dependence has been made in estimating the variance-covariance
matrix stored as component in vcov in the returned object.
coef, vcov, nobs and logLik methods are provided.
Value
fitBernoulli returns an object of class "Bernoulli", a list
with components: maxLogLik, mle, nobs, vcov,
n0, n1, data, obs_data, where data are
the input data and, obs_data are the input data after any missing
values have been removed, using na.omit and
n0 and n1 are, respectively, the number of failures and the
number of successes.
coef.Bernoulli: a numeric vector of length 1 with name prob.
The MLE of the probability of success.
vcov.Bernoulli: a 1 \times 1 matrix with row
and column name prob. The estimated variance of the estimator of
the probability of success. No adjustment for cluster dependence has
been made.
nobs.Bernoulli: a numeric vector of length 1 with name prob.
The number of observations used to estimate the probability of success.
logLik.Bernoulli: an object of class "logLik": a numeric
scalar with value equal to the maximised log-likelihood. The returned
object also has attributes nobs, the numbers of observations used
in this model fit, and "df" (degrees of freedom), which is equal
to the number of total number of parameters estimated (1).
Examples
# Set up data
cdata <- c(exdex::cheeseboro)
u <- 45
exc <- cdata > u
# Fit a Bernoulli distribution
fit <- fitBernoulli(exc)
# Calculate the log-likelihood at the MLE
res <- logLikVector(fit)
# The logLik method sums the individual log-likelihood contributions.
logLik(res)
# nobs, coef, vcov, logLik methods for objects returned from fitBernoulli()
nobs(fit)
coef(fit)
vcov(fit)
logLik(fit)