How to check if relationship between two variable changes over time? I am working on a commodity-exchange rate model as part of my thesis. My dependent variable is log of first difference of exchange rate of Colombia and my independent variable is log of first difference of crude petroleum price.
I have daily data for last 20 years for both the variable. I am interested in looking whether the relationship (i.e. the effect of crude petroleum prices on Colombia's exchange rate) between the two variables changes over time.
So let say i want to check whether effect of crude petroleum prices on Colombia's exchange rate in the last 5 years ( 2012-2017) is different from that in 2007-2012.
I was thinking of creating dummy variables for 5 years ( 1 if the data is from 2012-2017, 0 otherwise) and then creating an interaction variable of the dummy and crude petroleum prices.
I am not sure whether this is the right thing to do. also can i use any other model or test for the same. Any advice is appreciated. Please let me know if my question is unclear. I can try to modify it.   
 A: If you are trying to use an Ordinary Least Squares regression to determine the impact of crude petroleum prices on the Colombian exchange rate - the first thing you need to do is analyze your data to see if it is stationary. To do this, plot the autocorrelation function and run a Dickey-Fuller test adf.test in R to confirm/deny the same. Once you have confirmed that your model is stationary, i.e. you have a significant p-value for the Dickey-Fuller test at your specified significance level, then your OLS results are valid by regressing on first differences.
However, a more effective way to investigate the correlations between two time series is through cointegration analysis.
A cointegrated pair is one that is non-stationary, but a linear combination of that pair is stationary.
yt - βxt = ut
where xt and yt are a non-stationary and cointegrated pair.
When running the Engle-Granger two step method, the purpose of this is to estimate the value of ut through OLS and then regress the estimate of ut on the first differenced regression.
The reason that cointegration is preferred is that a normal correlation analysis or OLS in standard form will detect a trend from the time series, but this trend does not necessarily have theoretical meaning. This means that you would be quite likely to make a Type I error of rejecting the null hypothesis, or concluding a significant relationship exists when it doesn't.
A cointegration analysis accounts for the fact that a time trend could have been obtained due to chance, and therefore looks to see if the relationship between the two time series is statistically significant. While a stationary, first-differenced OLS is a valid procedure, your analysis would be well served with cointegration testing as well.
