elm.wfit: Fitting Linear Models

Description Usage Arguments Details Value Examples

View source: R/elm-wfit.R

Description

Efficient Linear Model Weighted Fit ("elm.wfit") is used to fit linear models in an equivalent way to "glm.fit" but in a reduced time depending on the design matrix and the family (or link).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
elm.wfit(
  x,
  y,
  weights = rep.int(1, n),
  offset = NULL,
  method = "qr",
  tol = 1e-07,
  singular.ok = TRUE,
  reduce = TRUE,
  ...
)

Arguments

x

logical values indicating whether the model matrix (x) and the response vector (y) used in the fitting process should be returned as components of the returned value.

y

logical values indicating whether the model matrix (x) and the response vector (y) used in the fitting process should be returned as components of the returned value.

weights

an optional vector of weights to be used in the fitting process. Should be NULL or a numeric vector. If non-NULL, weighted least squares is used with weights weights (that is, minimizing sum(w*e^2)); otherwise ordinary least squares is used.

offset

this can be used to specify an a priori known component to be included in the linear predictor during fitting. This should be NULL or a numeric vector or matrix of extents matching those of the response. One or more offset terms can be included in the formula instead or as well, and if more than one are specified their sum is used. See model.offset.

method

the method to be used in fitting the model. The default method "eglm.wfit" uses iteratively reweighted least squares (IWLS): the alternative "model.frame" returns the model frame and does no fitting. User-supplied fitting functions can be supplied either as a function or a character string naming a function, with a function which takes the same arguments as glm.fit from the stats package. If specified as a character string it is looked up from within the eflm namespace.

tol

tolerance for the qr decomposition. Default is 1e-7.

singular.ok

logical; if FALSE a singular fit is an error.

reduce

logical; if TRUE an alternate design matrix of p * p is used for the fitting instead of the traditional n * p design matrix.

...

For eglm: arguments to be used to form the default control argument if it is not supplied directly. For weights: further arguments passed to or from other methods.

Details

elm.wfit is a workhorse function: it is not normally called directly but can be more efficient where the response vector, design matrix and family have already been calculated. Use elm for most of the cases.

Value

A list that contains the same elements as the output from "lm.fit".

Examples

1
2
3
x <- cbind(rep(1, nrow(mtcars)), mtcars$wt)
y <- mtcars$mpg
elm.wfit(x, y)

eflm documentation built on June 1, 2021, 1:06 a.m.