rcompanion (version 2.2.2)

compareGLM: Compare fit statistics for glm models

Description

Produces a table of fit statistics for multiple glm models.

Usage

compareGLM(fits, ...)

Arguments

fits

A series of model object names, separated by commas.

...

Other arguments passed to list.

Value

A list of two objects: The series of model calls, and a data frame of statistics for each model.

Details

Produces a table of fit statistics for multiple glm models: AIC, AICc, BIC, p-value, pseudo R-squared (McFadden, Cox and Snell, Nagelkerke).

Smaller values for AIC, AICc, and BIC indicate a better balance of goodness-of-fit of the model and the complexity of the model. The goal is to find a model that adequately explains the data without having too many terms.

BIC tends to choose models with fewer parameters relative to AIC. For comparisons with AIC, etc., to be valid, both models must have the same data, without transformations, use the same dependent variable, and be fit with the same method. They do not need to be nested.

References

http://rcompanion.org/rcompanion/e_07.html

See Also

compareLM, pairwiseModelAnova, accuracy

Examples

Run this code
# NOT RUN {
### Compare among logistic regresion models
data(AndersonBias)
model.0 = glm(Result ~ 1, weight = Count, data = AndersonBias,
             family = binomial(link="logit"))
model.1 = glm(Result ~ County, weight = Count, data = AndersonBias,
             family = binomial(link="logit"))
model.2 = glm(Result ~ County + Sex, weight = Count, data = AndersonBias,
             family = binomial(link="logit"))
model.3 = glm(Result ~ County + Sex + County:Sex, weight = Count, 
             data = AndersonBias, family = binomial(link="logit"))
compareGLM(model.0, model.1, model.2, model.3)              

# }

Run the code above in your browser using DataLab