Chapter 1 – R Studio – Detailed Testing of Multicollinearity

This session will account to a detailed testing of multicollinearity. This include generation of a scatter plot matrix with correlation values and histograms useful for descriptive statistics. Further there is a wide array of tests including VIF, Tolerence test, |X’X| test etc.

importing libraries

library(tidyverse) # for data management
library(readxl) # to read excel file
library(mctest) # for multicollinearity tests
library(olsrr) # post regression tests
library(GGally) # scatter plot

importing data

auto <- read_excel(“D:/UMT notes/MPhil – MS courses/Applied Econometrics/lectures applied econometrics/lecture 6/stepwise regression/auto.xlsx”)

pairwise correlation plots

corr <- auto %>% select(mpg, displacement, price, weight, weight2, headroom, trunk, turn, length)
ggscatmat(corr, columns = 1: ncol(corr))

collinearity diagnostics type 1

auto <- auto %>% mutate(weight2 = weight^2)
model <- lm(mpg ~ displacement + price + weight + weight2 + headroom + trunk + turn + length, data = auto)
summary(model)
ols_correlations(model)

collinearity diagnostics type 2

x <- auto %>% select(displacement, price, weight, weight2, headroom, trunk, turn, length)
y <- auto %>% select(mpg)
mctest(x, y, method = “b”)
mctest(x, y, type=”i”)

collinearity diagnostics type 3

auto1 <- auto %>% select (-make, -foreign)
model1 <- mpg~displacement + price + weight + weight2 + headroom + trunk + turn + length
fit <- lm(model, auto1)
test<- ols_step_all_possible(fit)
par(mfrow=(3,2))
plot(test)

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top