Description Usage Arguments Details Value Author(s) References See Also Examples
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.
1 2 3 4 |
x |
as for |
y |
as for |
weights |
as for |
start |
as for |
etastart |
as for |
mustart |
as for |
offset |
as for |
family |
as for |
control |
as for |
intercept |
as for |
singular.ok |
as for |
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.
The value returned by glm.fit2 has exactly the same documentation as the value returned by glm.fit.
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.
Marschner, I.C. (2011) glm2: Fitting generalized linear models with convergence problems. The R Journal, Vol. 3/2, pp.12-15.
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))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.