Learn R Programming

itsadug (version 0.8)

compareML: Function for comparing two GAMM models.

Description

Function for comparing two GAMM models.

Usage

compareML(model1, model2)

Arguments

model1
First model.
model2
Second model.

Value

  • Optionally returns the Chi-Square test table.

Details

As an Chi-Square test is performed on two times the difference in minimized smoothing parameter selection score (GCV, fREML, REML, ML), and the difference in degrees of freedom specified in the model. The degrees of freedom of the model terms are the sum of 1) the number of estimated smoothing parameters for the model, 2) number of parametric (non-smooth) model terms including the intercept, and 3) the sum of the penalty null space dimensions of each smooth object.

This method is preferred over other functions such as AIC for models that include an AR1 model or random effects (especially nonlinear random smooths using bs="fs"). CompareML also reports the AIC difference, but that value should be treated with care.

Note that the Chi-Square test will result in a very low p-value when the difference in degrees of freedom approaches zero. Use common sense to determine if the difference between the two models is meaningful. A warning is presented when the difference in score is smaller than 5.

The order of the two models is not important. Model comparison is only implemented for the methods GCV, fREML, REML, and ML.

See Also

For models without AR1 model or random effects AIC can be used.

Examples

Run this code
data(simdat)

# some arbitrary models:
m1 <- bam(Y~Group + s(Time, by=Group), method="fREML", data=simdat)
m2 <- bam(Y~Group + s(Time), method="fREML", data=simdat)

compareML(m1, m2)

Run the code above in your browser using DataLab