ISYE 6501 HW 08 Data Warehousing and Foundations of
Business Intelligence (California State University, Fullerton)
Tran Tran
ISYE 6501
5 March 2025
Homework 8
Question 11.1
#a. stepwise
> # call out data from data table
> rm(list = ls())
> set.seed(42)
> data = read.table("/Users/joeytran/Downloads/hw5/uscrime.txt", header = TRUE)
>
> #now we need to create our initial model 1 for stepwise regression
> model = lm(Crime~., data = data)
>
> step (
+ model, scope = list(lower_sc = formula(lm(Crime~., data = data)),
+ upper_sc = formula(lm(Crime~., data = data))),
+ direction = "both"
+)
Start: AIC=514.65
Crime ~ M + So + Ed + Po1 + Po2 + LF + M.F + Pop + NW + U1 +
U2 + Wealth + Ineq + Prob + Time
Call:
, lOMoARcPSD|67928686
lm(formula = Crime ~ M + So + Ed + Po1 + Po2 + LF + M.F + Pop +
NW + U1 + U2 + Wealth + Ineq + Prob + Time, data = data)
Coefficients:
(Intercept) M So Ed Po1 Po2 LF
-5.984e+03 8.783e+01 -3.803e+00 1.883e+02 1.928e+02 -1.094e+02 -6.638e+02
M.F Pop NW U1 U2 Wealth Ineq
1.741e+01 -7.330e-01 4.204e+00 -5.827e+03 1.678e+02 9.617e-02 7.067e+01
Prob Time
-4.855e+03 -3.479e+00
>
> #As shown on the result for stepwise regression above, it have removed 7 factors that
> #do not have significance
>
> #using the remainder of the factors, we're going to put together a new model that
> #works for the given data
> model1 = lm(Crime~M+Ed+Po1+M.F+U1+U2+Ineq+Prob, data = data)
> summary(model1)
Call:
lm(formula = Crime ~ M + Ed + Po1 + M.F + U1 + U2 + Ineq + Prob,
data = data)
Residuals:
Min 1Q Median 3Q Max -444.70
-111.07 3.03 122.15 483.30
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -6426.10 1194.61 -5.379 4.04e-06 ***
M 93.32 33.50 2.786 0.00828 **