# Time series - correlation and lag time

I am studying the correlation between a set of input variables and a response variable, price. These are all in time series.

1) Is it necessary that I smooth out the curve where the input variable is cyclical (autoregressive)? If so, how?

2) Once a correlation is established, I would like to quantify exactly how the input variable affects the response variable. Eg: "Once X increases >10% then there is an 2% increase in y 6 months later."

How should I implement this - in particular to figure out the lag time between two correlated occurrences?

Example:

I already looked at: statsmodels.tsa.ARMA but it seems to deal with predicting only one variable over time. In scipy the covariance matrix can tell me about the correlation, but does not help with figuring out the lag time.

I do not personally code with python but I found out this:

So you have two vectors which both might have temporal dependencies.

You should first do this:

https://onlinecourses.science.psu.edu/stat510/?q=book/export/html/75

• Both resources are helpful, thanks. Will accept the answer once I implement. Any other resources you come across would be most welcome. Aug 15 '14 at 6:00

Finally, I used dynlm package in R.

model <- dynlm(Y ~ X + L(X, 1))


gives me a lag term of 1 interval. The package supports a multiplicative model, log, etc. Operates similar to lm.

1. Yes, smoothing out the curve is necessary. I used the gam function in gcmv library to remove the trend and cycles (The family argument allows you to experiment with different smoothing methods). You would extract the residuals of the gam model using gam.residuals, and use the residuals to do any further analysis.

2. The cross correlation function is what you should be looking at. The ccf function is helpful. Go check out more at this page. The CCF allows you to determine how two series are related to each other and the lag at which they are related.