Skip to contents

Test linear regression assumptions easily with a nice summary table.

Usage

nice_assumptions(model, interpretation = TRUE)

Arguments

model

The lm object to be passed to the function.

interpretation

Whether to display the interpretation helper or not.

See also

Examples

# Create a regression model (using data available in R by default)
model <- lm(mpg ~ wt * cyl + gear, data = mtcars)
nice_assumptions(model)
#> Interpretation: (p) values < .05 imply assumptions are not respected. Diagnostic is how many assumptions are not respected for a given model or variable. 
#> 
#>                Model... Normality (Shapiro-Wilk)...
#> 1 mpg ~ wt * cyl + gear                       0.615
#>   Homoscedasticity (Breusch-Pagan)...
#> 1                               0.054
#>   Autocorrelation of residuals (Durbin-Watson)... Diagnostic...
#> 1                                           0.525             0

# Multiple dependent variables at once
DV <- names(mtcars[-1])
formulas <- paste(DV, "~ mpg")
models.list <- lapply(X = formulas, FUN = lm, data = mtcars)
assumptions.table <- do.call("rbind", lapply(models.list, nice_assumptions,
  interpretation = FALSE
))
assumptions.table
#>      Model... Normality (Shapiro-Wilk)... Homoscedasticity (Breusch-Pagan)...
#> 1   cyl ~ mpg                       0.361                               0.282
#> 2  disp ~ mpg                       0.506                               0.831
#> 3    hp ~ mpg                       0.004                               0.351
#> 4  drat ~ mpg                       0.939                               0.887
#> 5    wt ~ mpg                       0.020                               0.270
#> 6  qsec ~ mpg                       0.427                               0.944
#> 7    vs ~ mpg                       0.142                               0.568
#> 8    am ~ mpg                       0.074                               0.650
#> 9  gear ~ mpg                       0.001                               0.528
#> 10 carb ~ mpg                       0.008                               0.362
#>    Autocorrelation of residuals (Durbin-Watson)... Diagnostic...
#> 1                                            0.460             0
#> 2                                            0.077             0
#> 3                                            0.198             1
#> 4                                            0.505             0
#> 5                                            0.002             2
#> 6                                            0.011             1
#> 7                                            0.238             0
#> 8                                            0.000             1
#> 9                                            0.000             2
#> 10                                           0.003             2