Chapter 1 – R Studio – Stepwise Regressions

This session details on estimating Stepwise regression in R Studio as a solution to weak multicollinearity.

importing libraries

library(tidyverse) # for data management
library(readxl) # to read excel file
library(olsrr) # post regression tests

importing data

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

Stepwise regression

swr <- lm(mpg ~ displacement + price + weight + weight2 + headroom + trunk + turn + length, data = auto)
stp_s <- ols_step_both_p(swr, pent = 0.2, prem = 0.3, details = TRUE)
plot(stp_s)

Leave a Comment

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

Scroll to Top