
Calculate log-likelihood for Beta-distributed proportions
Source:R/calc_log_likelihood_distributions.R
calc_log_likelihood_beta.RdComputes the total log-likelihood for proportion data under the Beta distribution.
Supports either the mean-precision parameterization (default) or the standard
shape parameterization. In both cases, a single global set of shape parameters is
estimated from the data using the method of moments. Each observation can be
weighted via weights.
Usage
calc_log_likelihood_beta(
observed,
estimated,
mean_precision = TRUE,
weights = NULL,
verbose = TRUE
)Arguments
- observed
Numeric vector of observed values in (0, 1).
- estimated
Numeric vector of model-predicted values in (0, 1).
- mean_precision
Logical; if
TRUE(default), use mean-precision parameterization. IfFALSE, estimate shape parameters directly from the observed vector.- weights
Optional numeric vector of non-negative weights, same length as
observed. Default isNULL, which sets all weights to 1.- verbose
Logical; if
TRUE, prints shape parameter estimates and total log-likelihood.
Details
When mean_precision = TRUE, the precision parameter \(\phi\) is estimated as:
$$
\phi = \frac{\mu (1 - \mu)}{\text{Var}(Y)} - 1
$$
Then:
$$
\text{shape}_1 = \mu_t \phi, \quad \text{shape}_2 = (1 - \mu_t) \phi
$$
When mean_precision = FALSE, a single global \(\text{shape}_1\), \(\text{shape}_2\)
is estimated from the observed vector:
$$
\text{shape}_1 = \left( \frac{1 - \mu}{\sigma^2} - \frac{1}{\mu} \right) \mu^2
$$
$$
\text{shape}_2 = \text{shape}_1 \left( \frac{1}{\mu} - 1 \right)
$$
The total log-likelihood is then summed across observations, each multiplied by weights[i].