Skip to contents

Fits the same beta regression model as fast_beta_regression_cpp (see that page for the full model, parameterization, and optimizer contract), with each observation's contribution to the log-likelihood, score, and Hessian multiplied by a nonnegative row weight weights[i]. Setting all weights to 1 recovers fast_beta_regression_cpp exactly; this is the backend the package's Inference classes use whenever the beta regression must be fit on bootstrap-reweighted or otherwise weighted data (e.g. Bayesian bootstrap weights) without physically resampling rows.

Usage

fast_beta_regression_weighted_cpp(
  X,
  y,
  weights,
  warm_start_beta = NULL,
  smart_cold_start = TRUE,
  start_phi = 10,
  compute_std_errs = FALSE,
  fixed_idx = NULL,
  fixed_values = NULL,
  optimization_alg = "lbfgs",
  warm_start_fisher_info = NULL,
  estimate_only = FALSE
)

Arguments

X

A numeric matrix of predictors, \(n \times p\).

y

A numeric vector of responses, strictly in \((0, 1)\).

weights

A nonnegative, finite numeric vector of length nrow(X) giving each row's weight; must sum to a positive value (see Details).

warm_start_beta

Optional starting values for coefficients \(\beta\). If provided, smart_cold_start is ignored.

smart_cold_start

Logical. If TRUE, use an initial OLS-based guess when no warm start is provided.

start_phi

Starting value for the precision parameter \(\phi\) (natural scale).

compute_std_errs

Deprecated; has no effect on this estimate-only entry point.

fixed_idx

Optional integer indices (into the c(beta, log(phi)) parameter layout) of parameters to hold fixed rather than estimate.

fixed_values

Optional values to fix the parameters named by fixed_idx at.

optimization_alg

Optimization algorithm; see fast_beta_regression_cpp.

warm_start_fisher_info

Optional initial Fisher Information matrix to warm-start curvature information.

estimate_only

If TRUE, skip Fisher information calculation.

Value

A list with the same components as fast_beta_regression_cpp: coefficients, phi, neg_loglik (the weighted negative log-likelihood), converged, and fisher_information.

Details

Input validation. weights must have length nrow(X), be finite and non-negative, and sum to a strictly positive value; violating any of these raises an error immediately rather than producing a degenerate fit. A weight of 0 for a given row contributes nothing to the likelihood (effectively excludes that row) without changing \(n\) in downstream index bookkeeping.

See also

fast_beta_regression_cpp for the unweighted model and full parameterization documentation; fast_beta_regression_with_var_cpp for the (unweighted) variance-augmented variant.