Skip to contents

Runs an IRLS loop with Beta working responses/weights and calls glmnet on the weighted least-squares surrogate. Supports BIC/AIC/CV model choice and an optional prestandardize speedup. The helper uses only the mean submodel, requires complete cases, and does not expose offset terms.

Usage

betareg_glmnet(
  X,
  Y,
  alpha = 1,
  choose = c("bic", "aic", "cv"),
  nfolds = 5,
  n_iter = 6,
  tol = 1e-05,
  standardize = TRUE,
  lambda = NULL,
  phi_init = 20,
  update_phi = TRUE,
  phi_maxit = 5,
  prestandardize = FALSE,
  trace = FALSE
)

Arguments

X

Numeric matrix (n × p) of mean-submodel predictors.

Y

Numeric response in (0,1). Values are squeezed to (0,1) internally.

alpha

Elastic-net mixing parameter.

choose

One of "bic", "aic", or "cv" to pick lambda.

nfolds

Folds for CV when choose = "cv".

n_iter

Max IRLS iterations;

tol

Convergence tolerance for the IRLS parameter change (Euclidean norm of the difference in [a0, beta]), default 1e-5.

standardize

Forwarded to glmnet (ignored if prestandardize = TRUE).

lambda

Optional fixed lambda; if NULL, chosen by choose.

phi_init

Initial precision (phi).

update_phi

Logical; update phi inside the IRLS loop.

phi_maxit

Newton steps for phi update.

prestandardize

If TRUE, manually center/scale X once and disable glmnet's internal standardization (speed trick).

trace

Logical; print IRLS progress.

Value

Named numeric vector (Intercept) + colnames(X) with zeros for unselected variables.

Examples

set.seed(1); X <- matrix(rnorm(500), 100, 5); Y <- plogis(X[,1]-0.5*X[,3])
Y <- rbeta(100, Y*40, (1-Y)*40)
betareg_glmnet(X, Y, alpha = 1, choose = "bic", prestandardize = TRUE)
#> (Intercept)          X1          X2          X3          X4          X5 
#>  0.02373154  0.90342704  0.00000000 -0.44090079  0.00000000  0.00000000