Question
3. (30) The monthly values of the average hourly wages for U.S. apparel and textile workers for July 1981 to June 1987 are in the
3. (30) The monthly values of the average hourly wages for U.S. apparel and textile workers for July 1981 to June 1987 are in the wages object in the TSA package. Type library(TSA); data(wages); print(wages) in R to see the data set.
a. Plot the time series. What basic pattern do you see from the plot?
b. Fit a linear time trend model using least squares. Give the plot of the linear trend overlain on the data, and give the estimated regression equation.
c. Plot the standardized residuals from the linear regression over time. Comment on any notable pattern.
d. Fit a quadratic time trend model using least squares. Give the plot of the quadratic trend overlain on the data, and give the estimated regression equation. e. Plot the standardized residuals from the quadratic regression over time. Comment on any notable pattern.
I have the code for all of the parts except for part d. I am having trouble fitting a quadratic trend and having that show up like with the linear model. This is my code so far. Please help.
library(TSA) data(wages) print(wages)
plot.ts(wages) wages.lm = lm(wages~time(wages)) summary(wages.lm) abline(wages.lm) coef(wages.lm)
plot(rstandard(wages.lm))
plot.ts(wages) wages.qm = lm(wages~time(wages) + I(time(wages)^2)) summary(wages.qm)
#I couldn't figure out how to add the quadratic trend line with the linear. wages.sq <- seq(1981, 1987, 12) wagespredict <- predict(wages.qm) plot(wagespredict) lines(wagespredict) #So, this is what I stopped with.
coef(wages.qm) plot(rstandard(wages.qm))
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started