Fit univariate beta distribution via weighted MLE
fit_beta_mle_single.RdFits a Beta(alpha, beta) distribution to univariate data using weighted maximum likelihood estimation. Initializes parameters via weighted moment matching, then refines estimates using Newton-Raphson optimization.
Arguments
- x
numericvector of observations in the interval (0, 1)- w
numericvector of normalized weights that sum to 1. Must have the same length asx- tol
numericconvergence tolerance for gradient norm (default: 1e-6)- max_iter
integermaximum number of Newton-Raphson iterations (default: 100)- clip_eps
numericclipping epsilon for numerical stability. Values outside[clip_eps, 1 - clip_eps]are clipped. Default: same astol
Value
A list with components:
- alpha
fitted shape parameter (> 0)
- beta
fitted shape parameter (> 0)
- converged
logical indicating whether optimization converged
- iterations
number of Newton-Raphson iterations performed
Details
The function optimizes the weighted log-likelihood: $$\sum_i w_i \log f(x_i; \alpha, \beta)$$ where \(f(x; \alpha, \beta)\) is the beta density.
Algorithm:
Clip
xto[clip_eps, 1 - clip_eps]for numerical stabilityInitialize via weighted method of moments
Iteratively update parameters using Newton-Raphson with backtracking line search
Convergence declared when gradient norm <
tol
Numerical considerations:
Returns alpha = beta = 100 for degenerate cases (variance < 1e-10)
Uses backtracking line search to maintain positivity of parameters
Warns if Hessian becomes singular (determinant < 1e-10)
Warns if maximum iterations reached without convergence