Today we will be finally creating our long awaited GDP forecast. In order to create this forecast we have to combine both the forecast from our deterministic trend model and the forecast from our de-trended GDP model.

Our model for the trend is:

trendyx= 892.656210 + -30.365580*x + 0.335586*x2

where x2=x^2

and the vector length we will make out to the 278th observation:

> x=c(1:278)

and our model for the cyclical de-trended series is from an AR(10) process:

GDP.fit<-arima(dt,order=c(10,0,0),include.mean=FALSE)

So lets say we want to predict GDP 21 periods into the future. Type in the following for the cyclical forecast:

> GDP.pred<-predict(GDP.fit,n.ahead=21)

Now when we produce our forecast we can't just add trendyx + GDP.pred$pred because the vector lengths won't match. To see this use the length() function:

> length(trendyx)

[1] 278

> length(GDP.pred$pred)

[1] 21

In order to fix this problem we are going to remove the first 258 observations from trendyx so that we only have 21 left:

> true.trend<-trendyx[-c(1:257)]

> length(true.trend)

[1] 21

Now we can plot away without any technical difficulties:

> plot(GDP,type="l",xlim=c(40,75),ylim=c(5000,18500),main="GDP Predictions")

> lines(GDP.pred$pred+true.trend,col="blue")

> lines((GDP.pred$pred+true.trend)-2*GDP.pred$se,col="red")

> lines((GDP.pred$pred+true.trend)+2*GDP.pred$se,col="red")

This code results in the following plot:

The blue line represents our point forecast and the red lines represent our 95% Confidence Level interval forecast. I feel like the plot could be significantly cooler and therefore at its current appearance receives a 2 out of 10 for style. It's bland, the x-axis doesn't have dates and there's not even any background color. If this plot had a name it would be doodoo. A war must be fought against the army of lame plots. Epic battles will proceed. Plots will be lost. Only one victor will stand.

Keep Dancin',

Steven J.

Great post

ReplyDelete