This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.

#download data

install.packages(“Quandl”)

library(“Quandl”) library(tseries) #(1) data identification

unr <- Quandl(“FRED/UNRATE”, type=“zoo”)

summary(unr)

plot(unr)

str(unr)

head(unr)

tail(unr)

y <- unr

adf.test(y)

kpss.test(y)

d.y <-diff(y)

plot(d.y)

adf.test(d.y)

kpss.test(d.y) #in orginal model, we cannot regect H0 so there is stationarity, then we try first difference.in difference Y , we regect H0 so no stationarity.

par(mfrow=c(2,3)) plot(y, main=expression(y)) plot(ly, main=expression(log(y))) plot.new

plot(dly,main=expression(paste(Delta,“log(y)”))) plot(dly12,main=expression(paste(Delta[12],“log(y)”))) plot(dly12_1,main=expression(paste(Delta,Delta[12],“log(y)”)))

acf and Pacf

acf(coredata(y),type=“correlation”,lag=40,ylab=“”,main=“ACF”)

acf(coredata(y),type=“partial”,lag=40,ylab=“”,main=“PACF”)

acf(coredata(d.y),type=“correlation”,lag=40,ylab=“”,main=“ACF”)

acf(coredata(d.y),type=“partial”,lag=40,ylab=“”,main=“PACF”)

estimate model -

ARMA1<-arima(y,order=c(1,0,1)) ARMA1

tsdiag(ARMA1,gof.lag=12)

ARMA2<-arima(y,order=c(2,0,2)) ARMA2

tsdiag(ARMA2,gof.lag=12)

ARMA3<-arima(y,order=c(3,0,1)) ARMA3

tsdiag(ARMA3,gof.lag=12)

ARMA4<-arima(y,order=c(4,0,1)) ARMA4

tsdiag(ARMA4,gof.lag=12)

ARMA5<-arima(y,order=c(3,0,2)) ARMA5

tsdiag(ARMA5,gof.lag=12)

ARMA6<-arima(y,order=c(3,0,3)) ARMA6

tsdiag(ARMA6,gof.lag=12)

based on AIC values and Ljunb-Box tests we choose models 6,4,and2

forecasting

library(“forecast”)

ARMA2.fcast<-forecast(ARMA2,h=12) par(mfrow=c(2,2),cex=0.7,mar=c(2,4,3,1)) plot(ARMA2.fcast,xlim=c(2012,2018)) lines(y,12)

ARMA4.fcast<-forecast(ARMA4,h=12) par(mfrow=c(2,1),cex=0.7,mar=c(2,4,3,1)) plot(ARMA4.fcast,xlim=c(2012,2018)) lines(y,12)

ARMA6.fcast<-forecast(ARMA6,h=12) par(mfrow=c(2,1),cex=0.7,mar=c(2,4,3,1)) plot(ARMA6.fcast,xlim=c(2012,2018)) lines(y,12)