eglm.wfit: Fitting Generalized Linear Models

Description Usage Arguments Details Value Examples

View source: R/eglm-wfit.R

Description

Efficient Generalized Linear Model Weighted Fit ("eglm.wfit") is used to fit generalized 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
12
13
14
eglm.wfit(
  x,
  y,
  weights = rep.int(1, nobs),
  start = NULL,
  etastart = NULL,
  mustart = NULL,
  offset = rep.int(0, nobs),
  family = gaussian(),
  control = list(),
  intercept = TRUE,
  singular.ok = TRUE,
  reduce = FALSE
)

Arguments

x, y

For eglm.wfit: x is a design matrix of dimension n * p, and y is a vector of observations of length n, or a matrix with n rows.

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.

start

starting values for the parameters in the linear predictor.

etastart

starting values for the linear predictor.

mustart

starting values for the vector of means.

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.

family

a description of the error distribution and link function to be used in the model. This can be a character string naming a family function, a family function or the result of a call to a family function. See family for details of family functions.

control

a list of parameters for controlling the fitting process. For eglm.wfit this is passed to glm.control.

intercept

logical value indicating whether intercept should be included in the null model. Defaults to TRUE.

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.

Details

eglm.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 eglm for most of the cases.

Value

A list that contains the same elements as the output from "glm.fit", with the addition of the vector "good" that indicates with logicals which observations were used in the fitting process.

Examples

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

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