Fit a Generalized Linear Model

DESCRIPTION:
Produces an object of class "glm" which is a generalized linear fit of the data.

USAGE:
glm(formula, family = gaussian, data = <<see below>>,
    weights = <<see below>>, subset = <<see below>>, na.action = na.fail,
    start = <<see below>>, control, trace = F, model = F, x = F, y = T,
    contrasts = NULL, qr = F, ...)

REQUIRED ARGUMENTS:
formula:
a formula expression as for other regression models, of the form response ~ predictors. See the documentation of lm and formula for details.

OPTIONAL ARGUMENTS:
family:
a family object - a list of functions and expressions for defining the link and variance functions, initialization and iterative weights. Families supported are gaussian, binomial, poisson, Gamma, inverse.gaussian and quasi. Functions like binomial produce a family object, but can be given without the parentheses. Family functions can take arguments, as in binomial(link=probit).
data:
an optional data frame in which to interpret the variables occurring in the formula.
weights:
the optional weights for the fitting criterion.
subset:
expression saying which subset of the rows of the data should be used in the fit. This can be a logical vector (which is replicated to have length equal to the number of observations), or a numeric vector indicating which observation numbers are to be included, or a character vector of the row names to be included. All observations are included by default.
na.action:
a function to filter missing data. This is applied to the model.frame after any subset argument has been used. The default (with na.fail) is to create an error if any missing values are found. A possible alternative is na.omit, which deletes observations that contain one or more missing values.
start:
a vector of initial values on the scale of the linear predictor.
control:
a list of iteration and algorithmic constants. See glm.control for their names and default values. These can also be set as arguments to glm itself.
trace:
logical flag: if TRUE, details of the iterations are printed. This can also be set in the control argument.
model:
if TRUE, the model.frame is returned. If this argument is itself a model.frame, then the formula and data arguments are ignored, and model is used to define the model.
x:
logical flag: if TRUE, the model.matrix is returned.
y:
logical flag: if TRUE, the response variable is returned (default is TRUE).
contrasts:
a list of contrasts to be used for some or all of the factors appearing as variables in the model formula. The names of the list should be the names of the corresponding variables, and the elements should either be contrast-type matrices (matrices with as many rows as levels of the factor and with columns linearly independent of each other and of a column of one's), or else they should be functions that compute such contrast matrices.
qr:
logical flag: if TRUE, the QR decomposition of the model.matrix is returned.
...:
control arguments may be given directly, see the control argument.

VALUE:
an object of class glm is returned, which inherits from lm. See glm.object for details.

DETAILS:
The output can be examined by print, summary, plot, and anova. Components can be extracted using predict, fitted, residuals, deviance, formula, and family. It can be modified using update. It has all the components of an lm object, with a few more. Other generic functions that have methods for glm objects are drop1, add1, step and preplot. Use glm.object for further details.

The response variable must conform with the definition of family, for example factor or binary data if family=binomial is declared.

The model is fit using Iterative Reweighted Least Squares (IRLS). The working response and iterative weights are computed using the functions contained in the family object. GLM models can also be fit using the function gam. The workhorse of glm is the function glm.fit which expects an x and y argument rather than a formula.


REFERENCES:
McCullagh, P. and Nelder, J. A. (1983). Generalized Linear Models. Chapman and Hall, London.

SEE ALSO:
family , gam , glm.control , glm.object , lm .

EXAMPLES:
glm(skips ~ ., family = poisson, data = solder.balance)
glm(Kyphosis ~ poly(Age, 2) + (Number > 5)*Start,
    family = binomial, data = kyphosis)
glm(ozone^(1/3) ~ bs(radiation, 5) + poly(wind, temperature, degree = 2),
    data = air)