Homework4 - setwd("/Users/Bcollender/STAT 425") getwd()...

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

The preview shows page 2 - 4 out of 13 pages.
setwd("/Users/Bcollender/STAT 425")getwd()#question 1Data1 <- read.table("advertspend.dat", header=TRUE)Model1 <- lm(MILIMP~log(SPEND), data = Data1)par(mfrow = c(2,2))plot(Model1, add.smooth=FALSE)library(MASS)boxcox(Model1)bcmod <- boxcox(Model1, plotit = FALSE)bcmod$x[which.max(bcmod$y)]#question 2Data2 <- read.table("destroyers.dat", header = TRUE)origModel2 <- lm(Displacement~Length+Beam+Draft, data = Data2)Model2 <- lm(log(Displacement)~log(Length)+log(Beam)+log(Draft), data = Data2)par(mfrow = c(2,2))plot(Model2, add.smooth=FALSE)summary(Model2)point <- data.frame(Length=500, Beam = 69.5, Draft = 24)predict(Model2, point, interval = "prediction")exp(predict(Model2, point, interval = "prediction"))confint(Model2)
#question 3library(faraway)help(seatpos)Frwrd1 = lm(hipcenter~1, data = seatpos)indep.vars <- ~Age + Weight + Ht + Legadd1(Frwrd1, indep.vars, test = "F")Frwrd1 = update(Frwrd1, .~. + Ht)add1(Frwrd1, indep.vars, test = "F")Bkwrd1 = lm(hipcenter ~ Age + Weight + Ht + Leg, data = seatpos)drop1(Bkwrd1, test="F")Bkwrd1 = update(Bkwrd1, .~. - Weight)drop1(Bkwrd1, test="F")Bkwrd1 = update(Bkwrd1, .~. - Age)drop1(Bkwrd1, test="F")Bkwrd1 = update(Bkwrd1, .~. - Leg)drop1(Bkwrd1, test="F")library(leaps)x = model.matrix(hipcenter~Age+Weight+Ht+Leg-1, data = seatpos)y = seatpos$hipcenterbestmods = leaps(x,y,nbest=1)bestmodsCpplot(bestmods)colnames(x)[c(1,3,4)]
step(lm(hipcenter~1, data = seatpos), scope = ~Age + Weight + Ht + Leg, direction ="both")

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 13 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Fall
Professor
Ma,P
Tags
Summation, Sq RSS AIC, bestmods

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture