Load data & fit a model for occupational prestige

data(Prestige, package="carData")

type is really an ordered factor. Make it so.

Prestige$type <- ordered(Prestige$type, levels=c("bc", "wc", "prof")) # reorder levels

Main effects model

mod0 <- lm(prestige ~ education + income + women + type,
           data=Prestige)

The standard diagnostic plot (the regression quartet)

Simply plot the model object

op <- par(mfrow = c(2,2), mar=c(4,4,3,1)+.1)
plot(mod0)

par(op)

performance::check_model() plots

Below, I use the check_model function from the performance package. This is part of the easystats collection of packages. See: https://easystats.github.io/easystats/ for an overview.

Install and load packages

if(!require(easystats)) install.packages("easystats")
## Loading required package: easystats
## # Attaching packages: easystats 0.5.2
## v insight     0.18.2    v datawizard  0.5.1  
## v bayestestR  0.12.1    v performance 0.9.2  
## v parameters  0.18.2    v effectsize  0.7.0.5
## v modelbased  0.8.5     v correlation 0.8.2  
## v see         0.7.2     v report      0.5.5
library(easystats)
if(!require(performance)) install.packages("performance")   # also needs "see"
library(performance)

The default plot gives an array of six nicely done diagnostic plots

check_model(mod0)

# can specify `check="all"`, or a subset of these:
check <- c("vif", "qq", "normality", "linearity", "ncv", "homogeneity", "outliers")

check_model(mod0, check=c("normality", "linearity", "ncv", "homogeneity", "outliers"))

detrended QQ plots are often better

check_model(mod0, check="qq", detrend=TRUE)

Model reports

if(!require(report)) install.packages("report")
library(report)
report(mod0)
## We fitted a linear model (estimated using OLS) to predict prestige with
## education (formula: prestige ~ education + income + women + type). The model
## explains a statistically significant and substantial proportion of variance (R2
## = 0.83, F(5, 92) = 93.07, p < .001, adj. R2 = 0.83). The model's intercept,
## corresponding to education = 0, is at 0.18 (95% CI [-13.81, 14.18], t(92) =
## 0.03, p = 0.979). Within this model:
## 
##   - The effect of education is statistically significant and positive (beta =
## 3.66, 95% CI [2.38, 4.95], t(92) = 5.67, p < .001; Std. beta = 0.59, 95% CI
## [0.38, 0.80])
##   - The effect of income is statistically significant and positive (beta =
## 1.04e-03, 95% CI [5.22e-04, 1.56e-03], t(92) = 3.98, p < .001; Std. beta =
## 0.26, 95% CI [0.13, 0.39])
##   - The effect of women is statistically non-significant and positive (beta =
## 6.44e-03, 95% CI [-0.05, 0.07], t(92) = 0.21, p = 0.832; Std. beta = 0.01, 95%
## CI [-0.10, 0.12])
##   - The effect of type [linear] is statistically non-significant and positive
## (beta = 4.18, 95% CI [-1.35, 9.71], t(92) = 1.50, p = 0.137; Std. beta = 0.24,
## 95% CI [-0.08, 0.57])
##   - The effect of type [quadratic] is statistically significant and positive
## (beta = 4.79, 95% CI [1.72, 7.86], t(92) = 3.10, p = 0.003; Std. beta = 0.28,
## 95% CI [0.10, 0.46])
## 
## Standardized parameters were obtained by fitting the model on a standardized
## version of the dataset. 95% Confidence Intervals (CIs) and p-values were
## computed using a Wald t-distribution approximation., We fitted a linear model
## (estimated using OLS) to predict prestige with income (formula: prestige ~
## education + income + women + type). The model explains a statistically
## significant and substantial proportion of variance (R2 = 0.83, F(5, 92) =
## 93.07, p < .001, adj. R2 = 0.83). The model's intercept, corresponding to
## income = 0, is at 0.18 (95% CI [-13.81, 14.18], t(92) = 0.03, p = 0.979).
## Within this model:
## 
##   - The effect of education is statistically significant and positive (beta =
## 3.66, 95% CI [2.38, 4.95], t(92) = 5.67, p < .001; Std. beta = 0.59, 95% CI
## [0.38, 0.80])
##   - The effect of income is statistically significant and positive (beta =
## 1.04e-03, 95% CI [5.22e-04, 1.56e-03], t(92) = 3.98, p < .001; Std. beta =
## 0.26, 95% CI [0.13, 0.39])
##   - The effect of women is statistically non-significant and positive (beta =
## 6.44e-03, 95% CI [-0.05, 0.07], t(92) = 0.21, p = 0.832; Std. beta = 0.01, 95%
## CI [-0.10, 0.12])
##   - The effect of type [linear] is statistically non-significant and positive
## (beta = 4.18, 95% CI [-1.35, 9.71], t(92) = 1.50, p = 0.137; Std. beta = 0.24,
## 95% CI [-0.08, 0.57])
##   - The effect of type [quadratic] is statistically significant and positive
## (beta = 4.79, 95% CI [1.72, 7.86], t(92) = 3.10, p = 0.003; Std. beta = 0.28,
## 95% CI [0.10, 0.46])
## 
## Standardized parameters were obtained by fitting the model on a standardized
## version of the dataset. 95% Confidence Intervals (CIs) and p-values were
## computed using a Wald t-distribution approximation., We fitted a linear model
## (estimated using OLS) to predict prestige with women (formula: prestige ~
## education + income + women + type). The model explains a statistically
## significant and substantial proportion of variance (R2 = 0.83, F(5, 92) =
## 93.07, p < .001, adj. R2 = 0.83). The model's intercept, corresponding to women
## = 0, is at 0.18 (95% CI [-13.81, 14.18], t(92) = 0.03, p = 0.979). Within this
## model:
## 
##   - The effect of education is statistically significant and positive (beta =
## 3.66, 95% CI [2.38, 4.95], t(92) = 5.67, p < .001; Std. beta = 0.59, 95% CI
## [0.38, 0.80])
##   - The effect of income is statistically significant and positive (beta =
## 1.04e-03, 95% CI [5.22e-04, 1.56e-03], t(92) = 3.98, p < .001; Std. beta =
## 0.26, 95% CI [0.13, 0.39])
##   - The effect of women is statistically non-significant and positive (beta =
## 6.44e-03, 95% CI [-0.05, 0.07], t(92) = 0.21, p = 0.832; Std. beta = 0.01, 95%
## CI [-0.10, 0.12])
##   - The effect of type [linear] is statistically non-significant and positive
## (beta = 4.18, 95% CI [-1.35, 9.71], t(92) = 1.50, p = 0.137; Std. beta = 0.24,
## 95% CI [-0.08, 0.57])
##   - The effect of type [quadratic] is statistically significant and positive
## (beta = 4.79, 95% CI [1.72, 7.86], t(92) = 3.10, p = 0.003; Std. beta = 0.28,
## 95% CI [0.10, 0.46])
## 
## Standardized parameters were obtained by fitting the model on a standardized
## version of the dataset. 95% Confidence Intervals (CIs) and p-values were
## computed using a Wald t-distribution approximation. and We fitted a linear
## model (estimated using OLS) to predict prestige with type (formula: prestige ~
## education + income + women + type). The model explains a statistically
## significant and substantial proportion of variance (R2 = 0.83, F(5, 92) =
## 93.07, p < .001, adj. R2 = 0.83). The model's intercept, corresponding to type
## = , is at 0.18 (95% CI [-13.81, 14.18], t(92) = 0.03, p = 0.979). Within this
## model:
## 
##   - The effect of education is statistically significant and positive (beta =
## 3.66, 95% CI [2.38, 4.95], t(92) = 5.67, p < .001; Std. beta = 0.59, 95% CI
## [0.38, 0.80])
##   - The effect of income is statistically significant and positive (beta =
## 1.04e-03, 95% CI [5.22e-04, 1.56e-03], t(92) = 3.98, p < .001; Std. beta =
## 0.26, 95% CI [0.13, 0.39])
##   - The effect of women is statistically non-significant and positive (beta =
## 6.44e-03, 95% CI [-0.05, 0.07], t(92) = 0.21, p = 0.832; Std. beta = 0.01, 95%
## CI [-0.10, 0.12])
##   - The effect of type [linear] is statistically non-significant and positive
## (beta = 4.18, 95% CI [-1.35, 9.71], t(92) = 1.50, p = 0.137; Std. beta = 0.24,
## 95% CI [-0.08, 0.57])
##   - The effect of type [quadratic] is statistically significant and positive
## (beta = 4.79, 95% CI [1.72, 7.86], t(92) = 3.10, p = 0.003; Std. beta = 0.28,
## 95% CI [0.10, 0.46])
## 
## Standardized parameters were obtained by fitting the model on a standardized
## version of the dataset. 95% Confidence Intervals (CIs) and p-values were
## computed using a Wald t-distribution approximation.

model_dashboard()

easystats::model_dashboard() gives a comprehensive report, constructed with the report package Not run here because it generates a separate HTML file.

# model_dashboard(mod0, 
#                 output_file = "prestige-dashboard.html",
#                 output_dir = "examples")
IycgLS0tDQojJyB0aXRsZTogIkRpYWdub3N0aWMgcGxvdHMgZm9yIGxpbmVhciBtb2RlbHMiDQojJyBhdXRob3I6ICJNaWNoYWVsIEZyaWVuZGx5Ig0KIycgZGF0ZTogImByIGZvcm1hdChTeXMuRGF0ZSgpKWAiDQojJyBvdXRwdXQ6DQojJyAgIGh0bWxfZG9jdW1lbnQ6DQojJyAgICAgdGhlbWU6IHJlYWRhYmxlDQojJyAgICAgY29kZV9kb3dubG9hZDogdHJ1ZQ0KIycgLS0tDQoNCiMrIGVjaG89RkFMU0UNCmtuaXRyOjpvcHRzX2NodW5rJHNldCh3YXJuaW5nPUZBTFNFLCBtZXNzYWdlPUZBTFNFLCBSLm9wdGlvbnM9bGlzdChkaWdpdHM9NCkpDQoNCg0KIycgIyMgTG9hZCBkYXRh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