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”)
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”)