fred_qd <- read.csv("fred_qd.csv")
fred <- fred_qd
fred <- fred[-(1:2),]
fred$NX <- (fred$EXPGSC1-fred$IMPGSC1)
timeseries <- ts(fred[,-1],start=c(1959,1),frequency = 4)
gdp_ts <- timeseries[,("GDPC1")]
consumption_ts <- timeseries[,("PCECC96")]
investment_ts <- timeseries[,("GPDIC1")]
government_ts <- timeseries[,("GCEC1")]
netexports_ts <- timeseries[,("NX")]
Part 1: Random Walk
plot(gdp_ts)

plot(consumption_ts)

plot(investment_ts)

plot(government_ts)

plot(netexports_ts)

1. Using an eye test on the plotted time series, I determined that a
random walk with drift is most appropriate for GDP, consumption,
investment, and goverment spending since they all have distinct upward
trends. Net exports on the other hand flucuates around 0 and does not
have a clear trend so a random walk would be appropriate.
pacf(gdp_ts, plot = FALSE)
##
## Partial autocorrelations of series 'gdp_ts', by lag
##
## 0.25 0.50 0.75 1.00 1.25 1.50 1.75 2.00 2.25 2.50 2.75
## 0.988 0.003 -0.003 -0.008 0.000 -0.002 -0.003 -0.007 -0.004 -0.003 -0.009
## 3.00 3.25 3.50 3.75 4.00 4.25 4.50 4.75 5.00 5.25 5.50
## -0.014 0.010 -0.001 0.008 0.004 0.001 0.074 -0.099 -0.030 -0.003 0.004
## 5.75 6.00
## -0.001 -0.005
pacf(consumption_ts)

pacf(investment_ts, plot = FALSE)
##
## Partial autocorrelations of series 'investment_ts', by lag
##
## 0.25 0.50 0.75 1.00 1.25 1.50 1.75 2.00 2.25 2.50 2.75
## 0.985 -0.015 0.006 -0.003 -0.017 0.000 0.013 -0.029 -0.001 -0.032 -0.029
## 3.00 3.25 3.50 3.75 4.00 4.25 4.50 4.75 5.00 5.25 5.50
## 0.003 0.060 0.029 -0.017 -0.023 0.025 0.146 -0.132 -0.030 -0.025 -0.002
## 5.75 6.00
## -0.003 0.005
pacf(government_ts, plot = FALSE)
##
## Partial autocorrelations of series 'government_ts', by lag
##
## 0.25 0.50 0.75 1.00 1.25 1.50 1.75 2.00 2.25 2.50 2.75
## 0.988 0.002 -0.006 -0.020 -0.016 0.006 0.003 0.005 0.011 -0.005 -0.010
## 3.00 3.25 3.50 3.75 4.00 4.25 4.50 4.75 5.00 5.25 5.50
## -0.014 -0.005 -0.014 -0.019 0.008 -0.022 -0.035 0.033 -0.002 0.000 0.005
## 5.75 6.00
## 0.007 0.006
pacf(netexports_ts, plot = FALSE)
##
## Partial autocorrelations of series 'netexports_ts', by lag
##
## 0.25 0.50 0.75 1.00 1.25 1.50 1.75 2.00 2.25 2.50 2.75
## 0.979 -0.051 0.010 -0.018 -0.032 -0.009 -0.046 -0.023 -0.027 -0.136 -0.041
## 3.00 3.25 3.50 3.75 4.00 4.25 4.50 4.75 5.00 5.25 5.50
## 0.075 -0.023 0.029 0.002 0.010 0.068 0.142 -0.016 -0.002 -0.095 -0.061
## 5.75 6.00
## -0.006 -0.055
1. For all five variables of interest AR(1) seems the most
appropriate according to the lags.
library(forecast)
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo