glmSolve: Generalized linear model (glm) solvers

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

Description

glmsolve sequencially tries multiple glm solvers and returns the result from the success. This tries to avoid numerical instabilities that occassionally affect some glm solving routines. If one fails, the next solver will be tried.

Usage

1
2
3
4

Arguments

formula, family, data

Identical to those of glm.

control

A list of named control options that specifies the details for each solver. Named elements not used by any solver will be ignored.

solvers

A named list of glm solvers, default to glmSolvers. Each element is itself a list with components named solve, success, and result, each of which is an expression. solve is an expression used to fit the glm model, the result of which is assigned to an object ans. success is an expression that returns a logical scalar, indicating whether the solver has succeeded. It may refer to the ans returned by solve. Often, it will check the converged element of ans, or something similar. result is an expression that returns a glm object from the success solver. If the solver does not return a glm object, it is the duty of result expression to convert it to a glm object.

...

Additional arguments passed to solvers.

Format

glmSolvers is currently a list of length 4. See solvers argument for details and the example.

Details

Currently, the supported are solvers are c('glm', 'glm.fit3', 'nlminb', 'BFGS'). 'glm' is the one that comes with the default stats package. 'glm.fit3' is a modification with better stability (but slightly slower). 'nlminb' uses the general optimization routine nlminb. 'BFGS' uses the method='BFGS' option provided by optim.

Value

If at least one of the solvers succeed, an glm object will be returned from the success. If all solvers fail but at least one solver did not throw an error, the result from the last solver that did not throw an error will be returned. In this case, glmsolve will throw a warning, stating that none of the solvers succeeded. If all solvers ended up throwing errors, glmsolve will also throw an error, again stating that non of the solvers succeeded.

Author(s)

Long Qu

See Also

glm, nlminb, optim, nlsolve

Examples

1
2
3
4
5
6
7
str(glmSolvers) ## available solvers stored in glmSolvers object
## Taken from stats::glm:
counts <- c(18,17,15,20,10,20,25,13,12)
outcome <- gl(3,1,9)
treatment <- gl(3,3)
print(d.AD <- data.frame(treatment, outcome, counts))
glm.D93 <- glmsolve(counts ~ outcome + treatment, family = poisson())

gitlongor/QuasiSeq documentation built on May 17, 2019, 5:28 a.m.