setwd("C:/Users/Hossein/Downloads")
dat <- read.csv('data-table-B8(6).csv')
model <- lm(y~x1+x2,data = dat)
library(car)
summary(model)
##
## Call:
## lm(formula = y ~ x1 + x2, data = dat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -9.7716 -4.1656 0.0802 3.8323 8.3349
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.109e+01 1.669e+00 6.642 1.48e-07 ***
## x1 3.501e+02 3.968e+01 8.823 3.38e-10 ***
## x2 1.089e-01 9.983e-03 10.912 1.74e-12 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.782 on 33 degrees of freedom
## Multiple R-squared: 0.8415, Adjusted R-squared: 0.8319
## F-statistic: 87.6 on 2 and 33 DF, p-value: 6.316e-14
vif(model)
## x1 x2
## 1.016535 1.016535
model1<- lm(y~x1+x2+x1:x2,data = dat)
summary(model1)
##
## Call:
## lm(formula = y ~ x1 + x2 + x1:x2, data = dat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -7.0753 -3.6781 0.4395 3.1321 8.8448
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 12.50128 1.89347 6.602 1.92e-07 ***
## x1 256.73740 73.72914 3.482 0.00146 **
## x2 0.09879 0.01193 8.281 1.84e-09 ***
## x1:x2 0.76127 0.51026 1.492 0.14551
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.696 on 32 degrees of freedom
## Multiple R-squared: 0.8518, Adjusted R-squared: 0.8379
## F-statistic: 61.31 on 3 and 32 DF, p-value: 2.318e-13
vif(model1)
## x1 x2 x1:x2
## 3.639435 1.505416 3.822936
dat1 <- scale(dat,center = TRUE, scale = TRUE)
dat1 <- as.data.frame(dat1)
model2 <- lm(y~x1+x2,data = dat1)
summary(model2)
##
## Call:
## lm(formula = y ~ x1 + x2, data = dat1)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.83775 -0.35713 0.00688 0.32855 0.71458
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.737e-17 6.833e-02 0.000 1
## x1 6.165e-01 6.987e-02 8.823 3.38e-10 ***
## x2 7.625e-01 6.987e-02 10.912 1.74e-12 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.41 on 33 degrees of freedom
## Multiple R-squared: 0.8415, Adjusted R-squared: 0.8319
## F-statistic: 87.6 on 2 and 33 DF, p-value: 6.316e-14
vif(model2)
## x1 x2
## 1.016535 1.016535
model3 <- lm(y~x1+x2+x1:x2,data = dat1)
summary(model3)
##
## Call:
## lm(formula = y ~ x1 + x2 + x1:x2, data = dat1)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.60658 -0.31533 0.03768 0.26852 0.75829
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.01357 0.06771 0.200 0.842
## x1 0.61207 0.06868 8.912 3.51e-10 ***
## x2 0.78767 0.07066 11.147 1.49e-12 ***
## x1:x2 0.10943 0.07335 1.492 0.146
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.4026 on 32 degrees of freedom
## Multiple R-squared: 0.8518, Adjusted R-squared: 0.8379
## F-statistic: 61.31 on 3 and 32 DF, p-value: 2.318e-13
vif(model3)
## x1 x2 x1:x2
## 1.018439 1.078223 1.066356
In part a) the VIF values were close to 1, suggesting that intercolineraity is not a problem. However, when we added the interaction term in part b) it increased the VIF values (VIF>3) which is an indication of co-linearity. As expected, after standardization (part c) the VIF values of the first order model remained close to 1. But, the standardization reduced the VIF values of the model with first order interactions to close to 1. These results suggests that standardization has reduced the co-linearity problem in the model with first order interaction.