Check model assumptions
Value
A named list with one element per assumption checked
(linearity, independence, homoscedasticity,
normality, multicollinearity, outliers), each
containing assumption (character label), check (logical,
NA when the test could not decide, or NULL when no test
was run), details (character), and recommendation
(character). An additional overall element summarises the
number of assumptions checked, violated, and satisfied; an NA or
NULL check counts as neither.
Logistic regression assumes neither normal residuals nor a constant
variance, so for a logistic model normality and
homoscedasticity have a NULL check and a note saying so.
For a factor, multicollinearity is judged on GVIF^(1/Df), the
generalised VIF on the scale of an ordinary one.
Examples
# \donttest{
model <- tl_model(mtcars, mpg ~ wt + hp, method = "linear")
tl_check_assumptions(model)
#> Registered S3 method overwritten by 'car':
#> method from
#> na.action.merMod lme4
#> Model Assumptions Check Summary:
#> --------------------------------
#> Linearity: VIOLATED
#> Details: RESET-style test on powers of the fitted values: p-value = 0.002042
#> Recommendation: Consider non-linear transformations or polynomial terms
#> Independence: VIOLATED
#> Details: Durbin-Watson statistic: 1.3624
#> Recommendation: Possible autocorrelation in residuals. Check for time-series structure or clustering.
#> Homoscedasticity: SATISFIED
#> Details: Breusch-Pagan test p-value: 0.6438
#> Recommendation: Homoscedasticity assumption appears satisfied
#> Normality of Residuals: VIOLATED
#> Details: Shapiro-Wilk test p-value: 0.0343
#> Recommendation: Residuals may not be normally distributed. Consider transformations or robust regression.
#> No Multicollinearity: SATISFIED
#> Details: Maximum VIF: 1.7666
#> Recommendation: No serious multicollinearity detected
#> No Influential Outliers: VIOLATED
#> Details: 6 influential observations detected
#> Recommendation: Consider inspecting observations: 16, 17, 18, 20, 29 ... (and potentially others)
#> $linearity
#> $linearity$assumption
#> [1] "Linearity"
#>
#> $linearity$check
#> [1] FALSE
#>
#> $linearity$details
#> [1] "RESET-style test on powers of the fitted values: p-value = 0.002042"
#>
#> $linearity$recommendation
#> [1] "Consider non-linear transformations or polynomial terms"
#>
#>
#> $independence
#> $independence$assumption
#> [1] "Independence"
#>
#> $independence$check
#> [1] FALSE
#>
#> $independence$details
#> [1] "Durbin-Watson statistic: 1.3624"
#>
#> $independence$recommendation
#> [1] "Possible autocorrelation in residuals. Check for time-series structure or clustering."
#>
#>
#> $homoscedasticity
#> $homoscedasticity$assumption
#> [1] "Homoscedasticity"
#>
#> $homoscedasticity$check
#> [1] TRUE
#>
#> $homoscedasticity$details
#> [1] "Breusch-Pagan test p-value: 0.6438"
#>
#> $homoscedasticity$recommendation
#> [1] "Homoscedasticity assumption appears satisfied"
#>
#>
#> $normality
#> $normality$assumption
#> [1] "Normality of Residuals"
#>
#> $normality$check
#> [1] FALSE
#>
#> $normality$details
#> [1] "Shapiro-Wilk test p-value: 0.0343"
#>
#> $normality$recommendation
#> [1] "Residuals may not be normally distributed. Consider transformations or robust regression."
#>
#>
#> $multicollinearity
#> $multicollinearity$assumption
#> [1] "No Multicollinearity"
#>
#> $multicollinearity$check
#> [1] TRUE
#>
#> $multicollinearity$details
#> [1] "Maximum VIF: 1.7666"
#>
#> $multicollinearity$recommendation
#> [1] "No serious multicollinearity detected"
#>
#>
#> $outliers
#> $outliers$assumption
#> [1] "No Influential Outliers"
#>
#> $outliers$check
#> [1] FALSE
#>
#> $outliers$details
#> [1] "6 influential observations detected"
#>
#> $outliers$recommendation
#> [1] "Consider inspecting observations: 16, 17, 18, 20, 29 ... (and potentially others)"
#>
#>
#> $overall
#> $overall$status
#> [1] "4 assumption(s) appear to be violated. See details."
#>
#> $overall$n_checked
#> [1] 6
#>
#> $overall$n_violated
#> [1] 4
#>
#> $overall$n_satisfied
#> [1] 2
#>
#>
# }
