glm.fit2: Generalized Linear Models Fitting Method

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

glm.fit2 is identical to glm.fit in the stats package, except for a modification to the computational method that provides improved convergence properties. It is the default fitting method for glm2 and can also be used as an alternative fitting method for glm, instead of the default method glm.fit.

Usage

1
2
3
4
glm.fit2(x, y, weights = rep(1, nobs), start = NULL, 
    etastart = NULL, mustart = NULL, offset = rep(0, nobs), 
    family = gaussian(), control = list(), intercept = TRUE,
    singular.ok = TRUE)

Arguments

x

as for glm.fit

y

as for glm.fit

weights

as for glm.fit

start

as for glm.fit

etastart

as for glm.fit

mustart

as for glm.fit

offset

as for glm.fit

family

as for glm.fit

control

as for glm.fit

intercept

as for glm.fit

singular.ok

as for glm.fit

Details

glm.fit2 is a modified version of glm.fit in the stats package. The computational method in glm.fit2 uses a stricter form of step-halving to deal with numerical instability in the iteratively reweighted least squares algorithm. Whereas glm.fit uses step-halving to correct divergence and parameter space violations, glm.fit2 additionally uses step-halving to force the model deviance to decrease at each iteration, which improves the convergence properties. Like glm.fit, glm.fit2 usually would not be called directly. Instead, it is called by glm2 as the default fitting method. Like glm.fit, it is possible to call glm.fit2 directly if the response vector and design matrix have already been calculated, in which case it may be more efficient than calling glm2. It can also be passed to glm in the stats package, using the method argument, providing an alternative to the default fitting method glm.fit. See Marschner (2011) for a discussion of the need for a modified fitting method.

Value

The value returned by glm.fit2 has exactly the same documentation as the value returned by glm.fit.

Author(s)

glm.fit2 uses the code from glm.fit, whose authors are listed in the help documentation for the stats package. Modifications to this code were made by Ian Marschner.

References

Marschner, I.C. (2011) glm2: Fitting generalized linear models with convergence problems. The R Journal, Vol. 3/2, pp.12-15.

See Also

glm.fit

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
library(glm2)

#--- logistic regression null model ---------------#
# (intercept estimate = log(0.75/0.25) = 1.098612)

y <- c(1,1,1,0)
x <- rep(1,4)

#--- divergence of glm.fit to infinite estimate ---#
fit1 <- glm.fit(x,y, family=binomial(link="logit"),start=-1.81)
fit2 <- glm.fit2(x,y, family=binomial(link="logit"),start=-1.81)
print.noquote(c(fit1$coef,fit2$coef))

glm2 documentation built on May 2, 2019, 6:09 a.m.