Functions involved in making inferences about the probability of success in a Bernoulli distribution using maximum likelihood estimation.

fitBernoulli(data)

# S3 method for Bernoulli
coef(object, ...)

# S3 method for Bernoulli
vcov(object, ...)

# S3 method for Bernoulli
nobs(object, ...)

# S3 method for 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 na.omit.

object

A fitted model object returned from fitBernoulli().

...

Further arguments. None are used currently.

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).

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.

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)
#> 'log Lik.' -937.2539 (df=1)

# nobs, coef, vcov, logLik methods for objects returned from fitBernoulli()
nobs(fit)
#> [1] 7398
coef(fit)
#>       prob 
#> 0.02771019 
vcov(fit)
#>              prob
#> prob 3.641841e-06
logLik(fit)
#> 'log Lik.' -937.2539 (df=1)