Skip to content

Validate model argument

Source: R/utils.R ยท Help: ?checkModel

Checks that model is of class lm or glm. With enhanced = TRUE it also runs the soft checks of the deprecated checkModelEnhanced(): it warns when the residual degrees of freedom fall below six, when a near-perfect fit is detected (R\(^2 > 0.999\)), or, when data is given, when a variance inflation factor exceeds 10 (Belsley et al., 1980).

Usage

checkModel(model, data = NULL, enhanced = FALSE)

Arguments

model
An object to check.
data
Optional data.frame used when fitting model. With enhanced = TRUE it enables the multicollinearity check through performVIFDiagnostic().
enhanced
Logical. FALSE, the default, checks the class only.

Value

Invisible model if valid, otherwise an error is thrown.

Details

It does not check whether a test accepts model: it accepts a binomial or a Poisson glm, a survey::svyglm() fit and a fit with a zero weight, which the tests refuse, each with its own message. Which test accepts which model is set out in test_results, under Supported models.

The R-squared is that of the least-squares fit: for a glm with the Gaussian family and the identity link, that of the equivalent lm, which summary() of a glm does not report; for any other glm it is not checked. Before 0.16.0, enhanced = TRUE stopped on any glm with "missing value where TRUE/FALSE needed".

References

Belsley, D. A., Kuh, E., & Welsch, R. E. (1980). Regression Diagnostics: Identifying Influential Data and Sources of Collinearity. Wiley.