HW10Sol+_2_ - Solution to HW#10 HW 10 Exercises 10.5...

This preview shows page 1 - 3 out of 7 pages.

Solution to HW #10 HW 10 : Exercises 10.5, 10.9(a,b,c,d,e), 10.15, 11.6 10.5 (a) > brand <- read.table("/Volumes/Rachel/TA/2012 Spring W4315/CH06PR05.txt") > colnames(brand) <- c("Y","X1", "X2") > resY1 <- lm(Y~X1,data=brand)$residual > res21 <- lm(X2~X1,data=brand)$residual > resY2 <- lm(Y~X2,data=brand)$residual > res12 <- lm(X1~X2,data=brand)$residual > par(mfrow=c(1,2)) > plot(resY2~res12,ylab="e(Y|X2)",xlab="e(X1|X2)",main="Added variable plot for X1") > plot(resY1~res21,ylab="e(Y|X1)",xlab="e(X2|X1)",main="Added variable plot for X2") (b) The plots show a linear relationship between partial residuals, which indicate that a linear term in X 1 (X 2 ) might be a helpful addition to the regression model already containing X 2 (X 1 ). Hence the model in problem 6.5(b) is appropriate. ( c) Fit Y on X 1 : > lm(Y~X1,data=brand) Call: lm(formula = Y ~ X1, data = brand) Coefficients: (Intercept) X1 50.775 4.425
Fit X 2 on X 1 : > lm(X2~X1,data=brand) Call: lm(formula = X2 ~ X1, data = brand) Coefficients: (Intercept) X1 3.000e+00 -2.483e-17 Fit e(Y|X 1 ) on e(X 2 |X 1 ) through origin: > lm(resY1~res21-1) Call: lm(formula = resY1 ~ res21 - 1) Coefficients: res21 4.375 Therefore, Or: 10.9(a) > library(MASS) > lm.brand <- lm(Y~X1+X2,data=brand) > studres(lm.brand) > res.stud 1 2 3 4 5 6 7 -0.04085498 0.06128781 -1.36059879 1.38602483 -0.36694571 -0.66490618 -0.76716157 8 9 10 11 12 13 14 0.50461264 0.46506694 -0.60436295 1.82302030 0.97784298 -1.13966417 -2.10272640 15 16 1.48973208 0.24572878 > qt(1-0.1/2/16,(16-2-1)) [1] 3.256463 An observation is an outlier if the absolute value of its studentized residual is greater than t(1-0.1/(2n),n-p-1)=3.256. No outlier is observed in this case.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture