Homework5 - setwd/Users/Bcollender/STAT 425...

This preview shows page 1 - 5 out of 14 pages.

setwd("/Users/Bcollender/STAT 425") getwd() #question 1 Data1 <- read.table("destroyers.dat", header=TRUE) model1 <- lm(log(Displacement)~Length+Beam, data = Data1) summary(model1) model2 <- lm(log(Displacement)~Length+Beam+I(Length*Length)+I(Beam*Beam) +I(Length*Beam), data = Data1) summary(model2) anova(model1) anova(model2) SSR1 = sum(model1$residuals^2) SSR2 = sum(model2$residuals^2) FStat = ((SSR1-SSR2)/(3))/(SSR2/27) FStat 1-pf(FStat, 3, 27) Bkwrd1 = model2 drop1(Bkwrd1, test = "F") Bkwrd1 = update(Bkwrd1, .~. - Length) drop1(Bkwrd1, test = "F") #question 2 model3 <- lm(weight~feed, data = chickwts) par(mfrow=c(2,2))
plot(model3, add.smooth = FALSE) TukeyHSD(aov(chickwts$weight~chickwts$feed),conf.level = .95) #question 3 ?warpbreaks model4 <- lm(breaks~wool+tension+wool*tension, data = warpbreaks) summary(model4) par(mfrow=c(2,2)) plot(model4, add.smooth = FALSE) library(MASS) boxcox(model4) bcmod <- boxcox(model4, plotit = FALSE) model5 <- lm(log(breaks)~wool+tension+wool*tension, data = warpbreaks) summary(model5) par(mfrow=c(1,1)) interaction.plot(warpbreaks$tension,warpbreaks$wool,log(warpbreaks$breaks)) anova(model5) > setwd("/Users/Bcollender/STAT 425")
> getwd() [1] "/Users/BCollender/STAT 425" > #question 1 > Data1 <- read.table("destroyers.dat", header=TRUE) > model1 <- lm(log(Displacement)~Length+Beam, data = Data1) > summary(model1) Call: lm(formula = log(Displacement) ~ Length + Beam, data = Data1) 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,

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture