# STAT425_HW_5_Yilun_Luo.docx - STAT425 HW#5 Yilun Luo Yilun...

• Homework Help
• 10
• 100% (1) 1 out of 1 people found this document helpful

This preview shows page 1 - 4 out of 10 pages.

STAT425 HW#5 Yilun Luo Yilun Luo November 3, 2016 1 part(a) ds = read.table ( "destroyers.dat" ); fit1 = lm ( log (Displacement) ~ Length+Beam, data = ds) summary (fit1) ## ## Call: ## lm(formula = log(Displacement) ~ Length + Beam, data = ds) ## ## Residuals: ## Min 1Q Median 3Q Max ## -0.40664 -0.05649 0.05264 0.09835 0.23408 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) 4.6504403 0.1299365 35.790 < 2e-16 *** ## Length 0.0039436 0.0009044 4.361 0.000141 *** ## Beam 0.0352421 0.0066055 5.335 9.04e-06 *** ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## Residual standard error: 0.1487 on 30 degrees of freedom ## Multiple R-squared: 0.967, Adjusted R-squared: 0.9648 ## F-statistic: 439 on 2 and 30 DF, p-value: < 2.2e-16 part(b) fit2 = lm ( log (Displacement) ~ Length+Beam+ I (Length^ 2 )+ I (Beam^ 2 )+ I (Length*Beam), data = ds) summary (fit2) ## ## Call: ## lm(formula = log(Displacement) ~ Length + Beam + I(Length^2) + ## I(Beam^2) + I(Length * Beam), data = ds) ## ## Residuals: ## Min 1Q Median 3Q Max ## -0.144297 -0.032167 -0.007257 0.028312 0.160636 ## ## Coefficients:
## Estimate Std. Error t value Pr(>|t|) ## (Intercept) 2.919e+00 4.639e-01 6.292 9.84e-07 *** ## Length 6.895e-04 5.723e-03 0.120 0.90500 ## Beam 1.569e-01 4.459e-02 3.520 0.00155 ** ## I(Length^2) 4.801e-05 2.683e-05 1.789 0.08481 . ## I(Beam^2) 2.844e-03 1.524e-03 1.866 0.07290 . ## I(Length * Beam) -8.733e-04 4.175e-04 -2.092 0.04601 * ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## Residual standard error: 0.08167 on 27 degrees of freedom ## Multiple R-squared: 0.991, Adjusted R-squared: 0.9894 ## F-statistic: 596.5 on 5 and 27 DF, p-value: < 2.2e-16 part(c) From the output above, Beam and Length*Beam are terms that appear to be significant at the 0.05 level. This does not mean that all of the other terms can be removed. part(d) anova (fit1,fit2) ## Analysis of Variance Table ## ## Model 1: log(Displacement) ~ Length + Beam ## Model 2: log(Displacement) ~ Length + Beam + I(Length^2) + I(Beam^2) + ## I(Length * Beam) ## Res.Df RSS Df Sum of Sq F Pr(>F) ## 1 30 0.66311 ## 2 27 0.18009 3 0.48303 24.14 8.388e-08 *** ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 According to the ANOVA table, p-value is 8.388e-08 < ??=0.05 which indicates that full model is preferred. part(e) drop1 (fit2, test = "F" ) ## Single term deletions ## ## Model: ## log(Displacement) ~ Length + Beam + I(Length^2) + I(Beam^2) + ## I(Length * Beam) ## Df Sum of Sq RSS AIC F value Pr(>F) ## <none> 0.18009 -159.96 ## Length 1 0.000097 0.18018 -161.94 0.0145 0.905002 ## Beam 1 0.082627 0.26271 -149.50 12.3881 0.001553 **
## I(Length^2) 1 0.021352 0.20144 -158.26 3.2013 0.084806 .