Starting from:

$25

stats500 - HOMEWORK 7 - Solved

1.      Use the stackloss data in library(faraway) and fit a model with stack.loss as the response, the other three variables as predictors – consider the following methods:

(a)       Least squares

(b)      Least absolute deviations

(c)       Huber method

(d)      Least trimmed squares

Now use diagnostic methods to detect the existence of any outlier or influential point. Remove the point(s) and then repeat the process. Please comment on your analysis outcomes.

2.      Use the aatemp data from 1881 to 2000 and let temp be the response and year as the predictor and consider the following models:

•    Orthogonal Polynomials to the 4-th degree.

•    Orthogonal Polynomials to the 5-th degree.

•    Orthogonal Polynomials to the 6-th degree.

•    Cubic spline with three internally evenly spaced knots (see the R-comments below)

(a)       Is there an increasing linear trend in temperature?

(b)      Suppose we also fit the dataset using an AR-1 error structure for the 5-th degree orthogonal polynomial. Select one of the tests in the outcomes from ‘‘interval(g)’’ below to justify the use of LS without considering correlations among errors.

(c)       Based on these outcomes, would you suggest to use an polynomial with an even higher order to model this dataset?

3.      Use the ‘‘ozone’’ data set from Faraway library. You can use

> library("faraway")

> data(ozone)

> summary(ozone)

to learn about each variable in the data set. Fit a model with ‘‘O3’’ as the response and ‘‘temp’’, ‘‘humidity’’ and ‘‘ibh’’ as predictors and use the Box-Cox method to determine the best transformation on the response. Report your outcome. You may file the following comments helpful

library(faraway); data(aatemp) year<-aatemp$year[-(1:3)]; temp<-aatemp$temp[-(1:3)] out5<-lm(temp ~ poly(year, 5)) library(nlme)

g <- gls(temp ~ poly(year, 5), correlation=corAR1(form=~year), data=aatemp, subset=(1:115)[-(1:3)]) intervals(g) library(splines) choice<-seq(min(year), max(year), length =5); knots <- c(rep(choice[1],4), choice[2:4], rep(choice[5],4)) bx <- splineDesign(knots, year, outer.ok = TRUE) gs <- lm(temp ~ bx-1)

plot(year, temp) lines(year, fitted(out5), col=2, lwd=2) lines(year, fitted(gs), col=4, lwd=2)

More products