unemp <- read.table("fig.2.1.dat", header=FALSE) plot(unemp[,1]) un <- ts(unemp[,1], start=c(1992,4), freq=4) plot(un) plot(diff(un)) dun1 <- diff(un) class(dun1) dun2 <- diff(diff(un)) plot(dun2) lines(diff(dun2), col="red", lty=2) ttrend <- 1:length(un) polymod1 <- lm(un ~ ttrend) summary(polymod1)$adj.r.squared polymod2 <- lm(un ~ ttrend + I(ttrend^2)) summary(polymod2)$adj.r.squared polymod3 <- lm(un ~ ttrend + I(ttrend^2)+I(ttrend^3)) summary(polymod3)$adj.r.squared summary(polymod3) un.hat <- ts(fitted(polymod2), start=c(1992,4), freq=4) plot(un) lines(un.hat, col="red", lty=2)