Skip to contents

Fits the beta regression model of Ferrari and Cribari-Neto (2004) for a continuous response strictly in \((0, 1)\), with mean linked to the covariates via the logit link and a single (constant) precision parameter \(\phi\). See fast_beta_regression_cpp for the full model equation, parameter layout, and optimizer contract implemented by the C++ backend this function wraps; this page documents only the R-level fallback chain and response-scale conventions.

Usage

fast_beta_regression(
  X,
  y,
  start_phi = 10,
  optimization_alg = "lbfgs",
  warm_start_beta = NULL,
  warm_start_fisher_info = NULL
)

Arguments

X

A numeric matrix of predictor variables. It is assumed that an intercept column (e.g., a column of ones) is already included in X if desired.

y

A numeric vector of the response variable, with values strictly between 0 and 1. See sanitize_beta_response() (internal) for how boundary values (exact 0s/1s) are handled before fitting.

start_phi

A numeric value, the starting value for the precision parameter phi. Defaults to 10.

optimization_alg

Optimization algorithm: "lbfgs" (default) or "newton_raphson"; see .normalize_optimizer_algorithm.

warm_start_beta

Optional starting values for coefficients \(\beta\).

warm_start_fisher_info

Optional initial Fisher Information matrix, used to warm-start curvature information for the optimizer.

Value

A list containing the following components:

b

A numeric vector of the estimated beta regression coefficients \(\hat\beta\) (on the logit-of-mean scale: plogis(X %*% b) gives the fitted mean \(\hat\mu\)), from whichever stage of the fallback chain (see Details) ultimately succeeded.

phi

The estimated precision parameter \(\hat\phi\) (only present when the C++ backend or the betareg fallback succeeds; absent from the final OLS-on-logit(y) fallback, which has no precision parameter).

fisher_information

The working-weights Fisher information matrix from the C++ backend (see fast_beta_regression_cpp); only present when that backend succeeds.

Details

Fallback chain. The primary implementation uses the C++ backend (fast_beta_regression_cpp). If that errors, the function falls back to betareg, which is listed in Suggests and is not installed automatically with EDI. If betareg is also unavailable (or itself fails), a final fallback of OLS on logit(y) is used — this last resort is always available (no external dependency) but does not respect the beta distribution's mean-variance relationship or estimate \(\phi\) at all, so its coefficients should be treated as an approximate, non-model-based summary rather than a true beta-regression fit. Install betareg manually to enable the intermediate fallback. A warning() is issued whenever a fallback stage is used, naming which stage and the triggering error, so callers can detect when the primary fit failed even though a result was still returned.

Examples

X = cbind(1, matrix(rnorm(400), 100, 4)) # first column is the intercept
y = runif(100)
fit = fast_beta_regression(X, y)
fit$b   # logit-of-mean coefficients
#> [1] -0.11182724 -0.11629069 -0.16716034 -0.10762001  0.06769186
fit$phi # precision
#> [1] 1.644454