Fit a generalized linear model with secure convergence.
glmgam.fit(X, y, coef.start = NULL, tol = 1e-6, maxit = 50, trace = FALSE)
design matrix, assumed to be of full column rank. Missing values not allowed.
numeric vector of responses. Negative or missing values not allowed.
numeric vector of starting values for the regression coefficients
small positive numeric value giving convergence tolerance
maximum number of iterations allowed
logical value. If TRUE
then output diagnostic information at each iteration.
List with the following components:
numeric vector of regression coefficients
numeric vector of fitted values
residual deviance
number of iterations used to convergence. If convergence was not achieved then iter
is set to maxit+1
.
This function implements a modified Fisher scoring algorithm for generalized linear models, similar to the Levenberg-Marquardt algorithm for nonlinear least squares. The Levenberg-Marquardt modification checks for a reduction in the deviance at each step, and avoids the possibility of divergence. The result is a very secure algorithm that converges for almost all datasets.
glmgam.fit
is in principle equivalent to glm.fit(X,y,family=Gamma(link="identity"))
but with much more secure convergence.
Dunn, PK, and Smyth, GK (2018). Generalized linear models with examples in R. Springer, New York, NY. https://doi.org/10.1007/978-1-4419-0118-7
glmgam.fit
is called by mixedModel2Fit
.
glm
is the standard glm fitting function in the stats package.
# NOT RUN {
y <- rgamma(10, shape=5)
X <- cbind(1, 1:10)
fit <- glmgam.fit(X, y, trace=TRUE)
# }
Run the code above in your browser using DataLab