We have been gven the data of mortgage rates in US since 2005 to 2019. Using ARIMA the rates have been forecasted for the next 50 weeks.

1)Data Visuualization

par(mfrow=c(1,1))
plot.ts(mortgage)

par(mfrow=c(1,2))
acf(mortgage)
pacf(mortgage)

From the plot of timeseries, it is evident that the time series is non stationary. Also the ACF decreases gradually which implies that thge time series s non stationary. Let us perform the ADF test for non-stationarity.

2)Identification of the non-stationarity of the time series

adf.test(mortgage)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  mortgage
## Dickey-Fuller = -2.4764, Lag order = 8, p-value = 0.3767
## alternative hypothesis: stationary

The p-value is 0.43767 which is greater than 0.05. Hence we cannot reject the null that the time series is non stationary.Since it shows a drift, let us check for drift

test1<-ur.df(mortgage,type="drift", lags = 8)
summary(test1)
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression drift 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.22903 -0.04575 -0.00500  0.03759  0.52021 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)  
## (Intercept)  0.060846   0.026993   2.254   0.0246 *
## z.lag.1     -0.015040   0.006397  -2.351   0.0191 *
## z.diff.lag1  0.034969   0.042099   0.831   0.4065  
## z.diff.lag2  0.084459   0.042083   2.007   0.0452 *
## z.diff.lag3  0.013305   0.041887   0.318   0.7509  
## z.diff.lag4  0.044662   0.041910   1.066   0.2870  
## z.diff.lag5 -0.030559   0.040931  -0.747   0.4556  
## z.diff.lag6  0.014919   0.040974   0.364   0.7159  
## z.diff.lag7 -0.050975   0.040770  -1.250   0.2117  
## z.diff.lag8  0.051897   0.040797   1.272   0.2039  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.07569 on 559 degrees of freedom
## Multiple R-squared:  0.02667,    Adjusted R-squared:  0.011 
## F-statistic: 1.702 on 9 and 559 DF,  p-value: 0.08548
## 
## 
## Value of test-statistic is: -2.3511 2.9951 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau2 -3.43 -2.86 -2.57
## phi1  6.43  4.59  3.78

The test statistic is not more negative than the critical values, hence we conclude that the time series is non-stationary with a drift

  1. Parameter estimation
mortgage.diff.one<-diff(mortgage)
adf.test(mortgage.diff.one)
## Warning in adf.test(mortgage.diff.one): p-value smaller than printed p-
## value
## 
##  Augmented Dickey-Fuller Test
## 
## data:  mortgage.diff.one
## Dickey-Fuller = -8.0634, Lag order = 8, p-value = 0.01
## alternative hypothesis: stationary

After taking the first order difference, we get a p-value of 0.01 which is less than 0.05. Hence we reject the null hypothesis that the time series is non-stationary and conclude that the time series is stationary.

par(mfrow=c(1,2))
acf(mortgage.diff.one)
pacf(mortgage.diff.one)

The plot shows that the ACF cutts of at 2 and the PACF cutts off at 2. Lets fit an ARMA(2,2) model

Arima(mortgage,order=c(2,1,2))
## Series: mortgage 
## ARIMA(2,1,2) 
## 
## Coefficients:
##           ar1     ar2     ma1      ma2
##       -0.1713  0.5622  0.2246  -0.4294
## s.e.   0.1863  0.1736  0.2020   0.1870
## 
## sigma^2 estimated as 0.006115:  log likelihood=653.73
## AIC=-1297.45   AICc=-1297.35   BIC=-1275.66
#Checking for other models
Arima(mortgage,order=c(2,1,1))
## Series: mortgage 
## ARIMA(2,1,1) 
## 
## Coefficients:
##          ar1     ar2      ma1
##       0.2660  0.1183  -0.2229
## s.e.  0.3395  0.0500   0.3425
## 
## sigma^2 estimated as 0.006128:  log likelihood=652.63
## AIC=-1297.25   AICc=-1297.18   BIC=-1279.82

We see that ARIMA(2,1,2) has the lowest AIC, hence let’s fit this model.

model<-Arima(mortgage,order=c(2,1,2))

We see that ar1 is not significant,ma1 is also not significant. We fit the final model by fixing the ar1 and ma1 to 0.

model.revised<-Arima(mortgage,order=c(2,1,2),fixed=c(0,NA,0,NA))

Final model:

  1. Diagnostic checking
checkresiduals(model.revised)

## 
##  Ljung-Box test
## 
## data:  Residuals from ARIMA(2,1,2)
## Q* = 6.2337, df = 6, p-value = 0.3975
## 
## Model df: 4.   Total lags used: 10

We observe that the residuals are random and the ACF is not significant. The p-value is greater than 0.05 hence we cannot reject the null hypotheses that the residuals are white noise

5)Forecast for next 50 weeks

forecast(model.revised,h=50)
##     Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## 579       3.664420 3.564199 3.764642 3.511145 3.817696
## 580       3.672269 3.530535 3.814004 3.455505 3.889034
## 581       3.663575 3.482563 3.844587 3.386742 3.940409
## 582       3.667955 3.454785 3.881126 3.341939 3.993972
## 583       3.663104 3.418727 3.907480 3.289361 4.036846
## 584       3.665548 3.393521 3.937574 3.249519 4.081576
## 585       3.662840 3.364156 3.961524 3.206043 4.119638
## 586       3.664204 3.341055 3.987354 3.169989 4.158419
## 587       3.662693 3.316032 4.009355 3.132520 4.192867
## 588       3.663455 3.294778 4.032132 3.099612 4.227298
## 589       3.662611 3.272773 4.052450 3.066405 4.258818
## 590       3.663036 3.253128 4.072945 3.036136 4.289937
## 591       3.662566 3.233327 4.091804 3.006102 4.319030
## 592       3.662803 3.215067 4.110538 2.978051 4.347555
## 593       3.662540 3.196940 4.128140 2.950467 4.374614
## 594       3.662673 3.179869 4.145476 2.924288 4.401057
## 595       3.662526 3.163057 4.161995 2.898654 4.426398
## 596       3.662600 3.147004 4.178195 2.874064 4.451135
## 597       3.662518 3.131257 4.193779 2.850025 4.475012
## 598       3.662559 3.116082 4.209037 2.826794 4.498324
## 599       3.662514 3.101217 4.223810 2.804085 4.520942
## 600       3.662537 3.086803 4.238271 2.782027 4.543046
## 601       3.662511 3.072685 4.252337 2.760450 4.564572
## 602       3.662524 3.058934 4.266113 2.739413 4.585634
## 603       3.662510 3.045460 4.279560 2.718813 4.606206
## 604       3.662517 3.032294 4.292740 2.698674 4.626360
## 605       3.662509 3.019380 4.305638 2.678928 4.646090
## 606       3.662513 3.006732 4.318293 2.659583 4.665443
## 607       3.662509 2.994315 4.330702 2.640594 4.684423
## 608       3.662511 2.982130 4.342892 2.621958 4.703063
## 609       3.662508 2.970154 4.354862 2.603644 4.721372
## 610       3.662510 2.958386 4.366633 2.585646 4.739373
## 611       3.662508 2.946808 4.378208 2.567940 4.757077
## 612       3.662509 2.935417 4.389601 2.550518 4.774500
## 613       3.662508 2.924200 4.400817 2.533363 4.791653
## 614       3.662508 2.913151 4.411866 2.516466 4.808551
## 615       3.662508 2.902263 4.422753 2.499813 4.825203
## 616       3.662508 2.891529 4.433488 2.483397 4.841620
## 617       3.662508 2.880941 4.444075 2.467205 4.857811
## 618       3.662508 2.870496 4.454520 2.451230 4.873786
## 619       3.662508 2.860186 4.464830 2.435462 4.889554
## 620       3.662508 2.850007 4.475009 2.419895 4.905121
## 621       3.662508 2.839954 4.485062 2.404521 4.920495
## 622       3.662508 2.830023 4.494993 2.389332 4.935684
## 623       3.662508 2.820208 4.504808 2.374322 4.950694
## 624       3.662508 2.810507 4.514509 2.359485 4.965531
## 625       3.662508 2.800915 4.524101 2.344815 4.980201
## 626       3.662508 2.791428 4.533588 2.330307 4.994709
## 627       3.662508 2.782044 4.542972 2.315955 5.009061
## 628       3.662508 2.772759 4.552257 2.301754 5.023262
autoplot(forecast(model.revised,h=50))