Fit generalized linear models using iterative reweighted least squares (IRLS) with MLX providing the heavy lifting for weighted least squares solves. Final convergence is done at double precision on the cpu.
Usage
mlxs_glm(
formula,
family = mlxs_gaussian(),
data,
subset,
weights,
na.action = stats::na.exclude,
start = NULL,
control = list(),
...
)Arguments
- formula
Model formula.
- family
A mlxs family object (e.g.,
mlxs_gaussian(),mlxs_binomial(),mlxs_poisson()). You can use"gaussian"etc.- data
Optional data frame, tibble, or environment containing the variables in the model.
- subset
Optional expression for subsetting observations.
- weights
Optional non-negative observation weights.
- na.action
How to handle missing values.
- start
Starting values for the parameters in the linear predictor.
- control
Optional list of control parameters passed to
mlxs_glm_control(). Control parameters can includeepsilon,epsilon_f64,maxit,trace, andrank_tol.- ...
Additional arguments passed to the family function when
familyis supplied as a function or string.
Value
An object of class c("mlxs_glm", "mlxs_model") containing elements
similar to the result of stats::glm(). Unlike stats::glm(),
rank-deficient model matrices are rejected rather than fit with aliased
coefficients.
Examples
fit <- mlxs_glm(mpg ~ cyl + disp, family = mlxs_gaussian(), data = mtcars)
coef(fit)
#> (Intercept) cyl disp
#> 34.66099167 -1.58727658 -0.02058364