| glmlist | R Documentation |
glmlist creates a glmlist object containing a list of fitted glm objects with their names.
loglmlist does the same for loglm objects.
The intention is to provide object classes to facilitate model comparison,
extraction, summary and plotting of model components, etc., perhaps using
lapply or similar.
There exists a anova.glm method for glmlist objects. Here,
a coef method is also defined, collecting the coefficients from all models in
a single object of type determined by result.
glmlist(...)
loglmlist(...)
## S3 method for class 'glmlist'
coef(object, result=c("list", "matrix", "data.frame"), ...)
... |
One or more model objects, as appropriate to the function, optionally assigned names as in |
object |
a |
result |
type of the result to be returned |
The arguments to glmlist or loglmlist are of the form value or name=value.
Any objects which do not inherit the appropriate class glm or loglm are excluded, with a warning.
In the coef method, coefficients from the different models are matched by name in the list of
unique names across all models.
An object of class glmlist loglmlist, just like a list,
except that each model is given a name attribute.
Michael Friendly;
coef method by John Fox
The function llist in package Hmisc is similar, but perplexingly
more general.
The function anova.glm also handles glmlist objects
LRstats gives LR statistics and tests for a glmlist object.
data(Mental)
indep <- glm(Freq ~ mental+ses,
family = poisson, data = Mental)
Cscore <- as.numeric(Mental$ses)
Rscore <- as.numeric(Mental$mental)
coleff <- glm(Freq ~ mental + ses + Rscore:ses,
family = poisson, data = Mental)
roweff <- glm(Freq ~ mental + ses + mental:Cscore,
family = poisson, data = Mental)
linlin <- glm(Freq ~ mental + ses + Rscore:Cscore,
family = poisson, data = Mental)
# use object names
mods <- glmlist(indep, coleff, roweff, linlin)
names(mods)
# assign new names
mods <- glmlist(Indep=indep, Col=coleff, Row=roweff, LinxLin=linlin)
names(mods)
LRstats(mods)
coef(mods, result='data.frame')
#extract model components
unlist(lapply(mods, deviance))
res <- lapply(mods, residuals)
boxplot(as.data.frame(res), main="Residuals from various models")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.