R code & output of 2A > attach(data) > mod <- Im(Y™ X1+x2+x3+x4+x5, data=data) > summary(mod) Residuals: Min 1Q Median 3
Posted: Mon May 02, 2022 12:24 pm
R code & output of 2A > attach(data) > mod <- Im(Y™ X1+x2+x3+x4+x5, data=data) > summary(mod) Residuals: Min 1Q Median 3Q -3.5979 -0.8008 -0.1830 1.1948 2.9062 Max X1 Coefficients: Estimate Std. Error t value Pr(>It) (Intercept) 0.03286 0.57322 0.057 0.95505 1.04077 0.42539 2.447 0.02722 * X2 3.00749 0.51213 5.873 3.07e-05 *** X3 -1.00424 0.45833 -2.191 0.04465 * X4 2.09089 0.52661 3.970 0.00123 ** X5 -0.15944 0.73181 -0.218 0.83047 Residual standard error: 1.89 on 15 degrees of freedom Multiple R-squared: 0.8722, Adjusted R-squared: 0.8296 F-statistic: 20.48 on 5 and 15 DF, p-value: 3.23e-06 > anova(mod) Analysis of Variance Table X1 Response: Y Df Sum Sq Mean Sq F value Pr>F) 1 52.545 52.545 14.7077 0.0016227 ** X2 1 240.262 240.262 67.2506 6.338e-07 *** X3 1 7.912 7.912 2.2146 0.1574321 X4 1 64.953 64.953 18.1806 0.0006795 *** 1 0.170 0.170 0.0475 0.8304660 Residuals 15 53.590 3.573 X5
> Z <- cbind (X1, X2, X3, X4, X5) > anova(Im(Y*2)) Analysis of Variance Table Response: Y Df Sum Sq Mean Sq F value Pr (>F) z 5 306.65 61.329 8.7021 0.0004881 *** Residuals 15 105.72 7.048 > X <- cbind(rep(1, 21), X1, X2, x3, x4, X5) > anova(Im(Yºx)) Analysis of Variance Table Response: Y Df Sum Sq Mean Sq F value Pr(>F) х 5 365.84 73.168 20.48 3.23e-06 Residuals 15 53.59 3.573 > anova(ln(Y*X1+x3+x4, data = data)) Analysis of Variance Table Response: Y Df Sum Sq Mean Sq F value Pr(>F) X1 1 52.545 52.545 3.4747 0.07968 X3 1 11.721 11.721 0.7751 0.39093 X4 1 98.088 98.088 6.4864 0.02085. Residuals 17 257.077 15.122 > anova(ln(Y*X2+x3+x4, data = data)) Analysis of Variance Table Response: Y Df Sum Sq Mean Sq F value Pr(>F) X2 1 224.036 224.036 48.9224 2.16e-06 *** X3 1 19.081 19.081 4.1667 0.0570639 X4 1 98.464 98.464 21.5013 0.0002358 *** Residuals 17 77.850 4.579 > x0 <- c(1, -1.81, 1.215, 0.701, 0.519, 0.113)
> t(x0) %*% solve( (t(X)%*%) %*% x0 [,1] [1,] 0.369204 > hat_beta <- coef (mod) > that_beta) %*% xo [,1] (1,] 2.166337 > x1 <-c(1, 1.02, -0.376, 0.563, 1.219, -0.913) >t(x1) %*% solve((t(X)%-%)) %*% x1 [,1] [1,] 0.1734191 > t(coef (mod)) %*% x1 (,1) [1] 2.092607 > TT1 <- rbind(c(0,0,0,1,1,0), (0,0,1,0,0,1)) > TT2 <- rbind(c(0,1,1,0,0,0), (0,0,0,1,0,1)) > (SSH1<-t (hat_beta)%*%t (TT1)%*%solve (TT1%+%solve(t (x)%*%X)%*%t(TT1))%=%TT1%+What_beta) (,1) [1,2 102.4302 > (SSH2<-t (hat_beta) %*%t (TT2)%*%solve (TT2%*%solve(t (x)%*%x)%*%t (TT2))%=%TT2%+What_beta) 1,1) [1,] 146.0911 The following critical values may be used for the questions: F0.05,2,15 = 3.682, F0.05,4,15 = 3.055, F0.05,4,16 = 3.007, F0.05,5,15 = 2.901, F0.05,5,16 = 2.852 to.025,15 = 2.131, +0.025,16 = 2.120,0.05,15 = 1.753, +0.05.16 = 1.746 = =
Questions of 2A 2.1) Fit the assumed MLR by the least squares method. [1 mark] 2.2) One wants to test the significance of the assumed model. List all the assumptions needed. [2 marks] 2.3) Test the significance of the regression at level a = 0.05 by an ANOVA table. Interpret your conclusion within the data context. [5 marks] 2.4) Using the partial F test, test the hypothesis Ho : B2 = B5 = 0 v.s H : B2 # B5 #0 at level a = 0.05, where the B; denotes regression coefficient of covariate r, for i = 1,...5. (5 marks)
= 2.5) Find a 95% confidence interval on the mean response when xo 1.219,-0.913). (1.02,-0.376, 0.563, [3 marks]
> Z <- cbind (X1, X2, X3, X4, X5) > anova(Im(Y*2)) Analysis of Variance Table Response: Y Df Sum Sq Mean Sq F value Pr (>F) z 5 306.65 61.329 8.7021 0.0004881 *** Residuals 15 105.72 7.048 > X <- cbind(rep(1, 21), X1, X2, x3, x4, X5) > anova(Im(Yºx)) Analysis of Variance Table Response: Y Df Sum Sq Mean Sq F value Pr(>F) х 5 365.84 73.168 20.48 3.23e-06 Residuals 15 53.59 3.573 > anova(ln(Y*X1+x3+x4, data = data)) Analysis of Variance Table Response: Y Df Sum Sq Mean Sq F value Pr(>F) X1 1 52.545 52.545 3.4747 0.07968 X3 1 11.721 11.721 0.7751 0.39093 X4 1 98.088 98.088 6.4864 0.02085. Residuals 17 257.077 15.122 > anova(ln(Y*X2+x3+x4, data = data)) Analysis of Variance Table Response: Y Df Sum Sq Mean Sq F value Pr(>F) X2 1 224.036 224.036 48.9224 2.16e-06 *** X3 1 19.081 19.081 4.1667 0.0570639 X4 1 98.464 98.464 21.5013 0.0002358 *** Residuals 17 77.850 4.579 > x0 <- c(1, -1.81, 1.215, 0.701, 0.519, 0.113)
> t(x0) %*% solve( (t(X)%*%) %*% x0 [,1] [1,] 0.369204 > hat_beta <- coef (mod) > that_beta) %*% xo [,1] (1,] 2.166337 > x1 <-c(1, 1.02, -0.376, 0.563, 1.219, -0.913) >t(x1) %*% solve((t(X)%-%)) %*% x1 [,1] [1,] 0.1734191 > t(coef (mod)) %*% x1 (,1) [1] 2.092607 > TT1 <- rbind(c(0,0,0,1,1,0), (0,0,1,0,0,1)) > TT2 <- rbind(c(0,1,1,0,0,0), (0,0,0,1,0,1)) > (SSH1<-t (hat_beta)%*%t (TT1)%*%solve (TT1%+%solve(t (x)%*%X)%*%t(TT1))%=%TT1%+What_beta) (,1) [1,2 102.4302 > (SSH2<-t (hat_beta) %*%t (TT2)%*%solve (TT2%*%solve(t (x)%*%x)%*%t (TT2))%=%TT2%+What_beta) 1,1) [1,] 146.0911 The following critical values may be used for the questions: F0.05,2,15 = 3.682, F0.05,4,15 = 3.055, F0.05,4,16 = 3.007, F0.05,5,15 = 2.901, F0.05,5,16 = 2.852 to.025,15 = 2.131, +0.025,16 = 2.120,0.05,15 = 1.753, +0.05.16 = 1.746 = =
Questions of 2A 2.1) Fit the assumed MLR by the least squares method. [1 mark] 2.2) One wants to test the significance of the assumed model. List all the assumptions needed. [2 marks] 2.3) Test the significance of the regression at level a = 0.05 by an ANOVA table. Interpret your conclusion within the data context. [5 marks] 2.4) Using the partial F test, test the hypothesis Ho : B2 = B5 = 0 v.s H : B2 # B5 #0 at level a = 0.05, where the B; denotes regression coefficient of covariate r, for i = 1,...5. (5 marks)
= 2.5) Find a 95% confidence interval on the mean response when xo 1.219,-0.913). (1.02,-0.376, 0.563, [3 marks]