Problem 3 Sptember 11 analyzes monthly passanger movement data between january 1990 and April 2004

plot each of the three pre-event time series (Air,Rail,Car)

set uo the direction of the file+call the data and uplodod it to R + display structure

getwd()
## [1] "/Users/yusufsultan"
setwd("/Users/yusufsultan")
Ship <- read.csv("ApplianceShipments.csv")
str(Ship)
## 'data.frame':    20 obs. of  2 variables:
##  $ Quarter  : Factor w/ 20 levels "Q1-1985","Q1-1986",..: 1 2 3 4 5 6 7 8 9 10 ...
##  $ Shipments: int  4009 4123 4493 4595 4245 4321 4522 4806 4799 4900 ...
Ship.ts <- ts(Ship$Shipments, start=c(1985), end=c(1989), freq=4)
plot(Ship.ts, xlab="Time", ylab="Shipments", ylim=c(3500, 5000), bty="l")

quarterly <- aggregate(Ship.ts, nfrequency=4, FUN=sum)
plot(quarterly, bty="l")

library(forecast)
## Warning: package 'forecast' was built under R version 3.2.5
## Loading required package: zoo
## Warning: package 'zoo' was built under R version 3.2.5
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## Loading required package: timeDate
## This is forecast 7.3
ShipLinear <- tslm(Ship.ts ~ trend)
summary(ShipLinear)
## 
## Call:
## tslm(formula = Ship.ts ~ trend)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -486.03 -202.27   72.75  174.00  474.48 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 4417.9926   154.0939   28.67 1.62e-14 ***
## trend          0.7525    15.0380    0.05    0.961    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 303.8 on 15 degrees of freedom
## Multiple R-squared:  0.0001669,  Adjusted R-squared:  -0.06649 
## F-statistic: 0.002504 on 1 and 15 DF,  p-value: 0.9608
plot(Ship.ts, xlab="Time", ylab="Shipments", ylim=c(3500, 5000), bty="l")
lines(ShipLinear$fitted, lwd=2)

ShipQuad <- tslm(Ship.ts ~ trend + I(trend^2))
summary(ShipQuad)
## 
## Call:
## tslm(formula = Ship.ts ~ trend + I(trend^2))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -401.42 -100.41   -1.57  152.97  275.21 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 3850.426    172.440  22.329  2.4e-12 ***
## trend        179.984     44.102   4.081 0.001123 ** 
## I(trend^2)    -9.957      2.381  -4.182 0.000923 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 209.7 on 14 degrees of freedom
## Multiple R-squared:  0.5554, Adjusted R-squared:  0.4919 
## F-statistic: 8.745 on 2 and 14 DF,  p-value: 0.003433
lines(ShipQuad$fitted, lty=2, lwd=3)