I am building an autoregressive distributed lag model using the dLagM package in R.
One of the steps in the pipeline is to look at how two time series to be used to build the model are correlated.
I am using the suggested code for this step below, but I am getting the error shown. It seems that the error is caused by the fact that the 2 series being looked at do not have the same attributes. When I call "attribute" on the 2 series, it seems that the attributes are the same.
Is there something I am doing wrong?
Here is my code:
install.packages(Ecdat)
library(Ecdat)
inflation <- as.numeric(Mishkin[, 1])
inflation_ts <- ts(inflation,start=c(1950,2), frequency = 12)
install.packages("Quandl")
library(Quandl)
Quandl.api_key("ci9fxB")
gdp <- Quandl("FRED/GDP")
gdp <- gdp %>% arrange(-row_number())
gdp <- gdp$Value
gdp_diff <- diff(gdp)
gdp_short <- gdp[1:(length(gdp)-1)]
gdp_change <- (gdp_diff/gdp_short)*100
GDP_mon <- c(sapply(gdp_change, function(gdp_change) c(rep(NA,2),gdp_change)))
GDP_mon <- GDP_mon[2:(length(GDP_mon)-2)]
GDP_mon <- ts(GDP_mon,start=c(1947,1), frequency=12)
GDP_mon <- na_interpolation(GDP_mon, option = "stine")
GDP_mon <- window(GDP_mon,c(1950,2),c(1990,12))
rolCorPlot(y = inflation_ts, x = GDP_mon, width = c(3, 5, 7, 9), level = 0.95,
main = "Rolling correlations between sea levels and temperature",
SDtest = TRUE)
attributes(inflation_ts)
attributes(GDP_mon)