
Statistical Methods with R
Unit D · Chapter 10 · Lecture 10a
Developed by Jeffrey M. Girard
Overview
Correct Form
No Omitted Confounders
Perfect Predictors
No Collinearity
The linear model makes certain assumptions about the data
When these assumptions are violated, two main problems occur
Consequences of Violating
Bias in both coefficients and standard errors!


check_model(fit, check = "linearity")
With several predictors, a curve in one x can be diluted here; per-predictor residual plots help
education out made White Collar look more prestigious than Blue Collar, and putting it back reversed the signConsequences of Violating
Bias in the coefficients, and therefore in the tests and intervals built on them!
This is the assumption you cannot test, only defend.
Do not “control for everything”: adjusting for a mediator removes the very pathway you are studying.
Consequences of Violating
Bias in both coefficients and standard errors!
Error in y will bias standardized (but not unstandardized) coefficients.
Calculate predictors’ reliability (the opposite of error)
correlation::correlation()psych::omega()irr::icc()Consequences of Violating
Coefficients stay unbiased but become unstable; standard errors become larger, honestly reflecting that instability.
Unstable means the estimate swings a lot from sample to sample, not that it is systematically too high or too low.
If x_1 and x_2 overlap to a
very large degree, then…
\hat{y} = b_0 + b_1x_1 + b_2x_2

\text{VIF}_j = \frac{1}{1-R^2_j}
check_collinearity(fit)
Let’s simulate data with collinearity problems
y (Continuous)
height1, height2, weight, size (Continuous)
female, male (Binary)
height2 mirrors height1
size is multicollinear with height1 and weight
male duplicates female
round(cor(simdat), digits = 2)
## height1 height2 weight size female male y
## height1 1.00 0.97 0.07 0.72 0.15 -0.15 0.33
## height2 0.97 1.00 0.09 0.71 0.14 -0.14 0.29
## weight 0.07 0.09 1.00 0.72 0.16 -0.16 -0.66
## size 0.72 0.71 0.72 1.00 0.23 -0.23 -0.22
## female 0.15 0.14 0.16 0.23 1.00 -1.00 -0.05
## male -0.15 -0.14 -0.16 -0.23 -1.00 1.00 0.05
## y 0.33 0.29 -0.66 -0.22 -0.05 0.05 1.00height1 and height2 are highly correlated (r=.97)
female and male are perfectly correlated (r=-1.00)
However, size is not as correlated with height1 (r=.72)
or weight (r=.72) despite the three being multicollinear
fit_none <- lm(y ~ height1 + weight, data = simdat)
model_parameters(fit_none)
## Parameter | Coefficient | SE | 95% CI | t(97) | p
## -------------------------------------------------------------------
## (Intercept) | 10.02 | 0.12 | [ 9.80, 10.25] | 87.06 | < .001
## height1 | 0.20 | 0.04 | [ 0.13, 0.28] | 5.53 | < .001
## weight | -0.38 | 0.04 | [-0.45, -0.30] | -10.16 | < .001
r2(fit_none)
## # R2 for Linear Regression
## R2: 0.567
## adj. R2: 0.558Let’s calculate the VIFs for this model
fit_co <- lm(y ~ height1 + weight + height2, data = simdat)
model_parameters(fit_co)
## Parameter | Coefficient | SE | 95% CI | t(96) | p
## -------------------------------------------------------------------
## (Intercept) | 10.02 | 0.12 | [ 9.79, 10.25] | 86.61 | < .001
## height1 | 0.24 | 0.15 | [-0.05, 0.53] | 1.61 | 0.110
## weight | -0.38 | 0.04 | [-0.45, -0.30] | -10.04 | < .001
## height2 | -0.03 | 0.15 | [-0.32, 0.26] | -0.23 | 0.821
r2(fit_co)
## # R2 for Linear Regression
## R2: 0.567
## adj. R2: 0.553height1 slope is no longer significantLet’s calculate the VIFs for this model
check_collinearity(fit_co)
## # Check for Multicollinearity
##
## Low Correlation
##
## Term VIF VIF 95% CI adj. VIF Tolerance Tolerance 95% CI
## weight 1.01 [ 1.00, 5128.00] 1.01 0.99 [0.00, 1.00]
##
## High Correlation
##
## Term VIF VIF 95% CI adj. VIF Tolerance Tolerance 95% CI
## height1 15.71 [11.06, 22.49] 3.96 0.06 [0.04, 0.09]
## height2 15.76 [11.10, 22.58] 3.97 0.06 [0.04, 0.09]fit_mc <- lm(y ~ height1 + weight + size, data = simdat)
model_parameters(fit_mc)
## Parameter | Coefficient | SE | 95% CI | t(96) | p
## ------------------------------------------------------------------
## (Intercept) | 10.02 | 0.12 | [ 9.79, 10.25] | 85.93 | < .001
## height1 | 0.24 | 0.18 | [-0.11, 0.60] | 1.37 | 0.175
## weight | -0.34 | 0.18 | [-0.69, 0.01] | -1.92 | 0.058
## size | -0.04 | 0.18 | [-0.39, 0.31] | -0.22 | 0.828
r2(fit_mc)
## # R2 for Linear Regression
## R2: 0.567
## adj. R2: 0.553Let’s calculate the VIFs for this model
check_collinearity(fit_mc)
## # Check for Multicollinearity
##
## High Correlation
##
## Term VIF VIF 95% CI adj. VIF Tolerance Tolerance 95% CI
## height1 22.91 [16.05, 32.89] 4.79 0.04 [0.03, 0.06]
## weight 22.60 [15.84, 32.44] 4.75 0.04 [0.03, 0.06]
## size 47.41 [33.03, 68.25] 6.89 0.02 [0.01, 0.03]fit_xc <- lm(y ~ female + male, data = simdat)
model_parameters(fit_xc)
## Model matrix is rank deficient. Parameters `male` were not estimable.
## Parameter | Coefficient | SE | 95% CI | t(98) | p
## ------------------------------------------------------------------
## (Intercept) | 10.01 | 0.24 | [ 9.52, 10.49] | 40.89 | < .001
## female | -0.19 | 0.34 | [-0.87, 0.49] | -0.54 | 0.590
##
## Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
## using a Wald t-distribution approximation.male parametermale slope (it was dropped)