First of all please excuse my total lack of stats knowledge. I have only taken a couple back in my college days that I do not quite remember too much.

I have a time series of data such as this:

X     |     Y 
1           1000
10          1020
5           900
6           901
7           902
8           950
2           800

Every time X goes up or down so does Y. The amount X goes up/down each time is different than Y, but still there is some sort of relationship there.

I am trying to figure out if there is a method to determine that there is a relationship here. If I try to check the correlation it will give me an R value of R value of ~0.40 which is a weak relationship. What are the method or methods out there to determine that there is a relationship between these two sets? Regards.

Visually I can see there is a relationship but not sure how to quantify it.

  • $\begingroup$ I'm not too interested in the amount that the variable changes, just the direction (up/down). The correlation coefficient is quite weak for this dataset $\endgroup$ Jan 25, 2019 at 0:02
  • $\begingroup$ @user2924127 Is this a time series or not? It's far from clear to me. $\endgroup$
    – mkt
    Jan 25, 2019 at 9:16
  • $\begingroup$ @mkt yes, this a time series $\endgroup$ Jan 25, 2019 at 14:42

2 Answers 2


I believe you intend to treat these as time series. Then what you want to do is to do a cointegration analysis to see if these two series move together. Look up the Engle-Granger cointegration method (the 1st step in that method). Here are your next steps, with clarifications you requested:

Intuitively, 2 series are cointegrated if over the long term they will not move arbitrarily far apart. For example, finance theory suggests that interest rates should be cointegrated, with a cointegration coefficient of 1. I'll explain what that means in a second. I downloaded 2 series of interest rates for you from the St. Louis Federal Reserve website to verify this claim. The cointegration claim in our example is that, over the long run, the 10 Year Rate series and the 6 Month Rate series will not move arbitrarily far from each other. Notice that both the 10 Year and the 6 Month series have a downward trend, but their difference (gray line) doesn't have a trend. While the gray line may increase or decrease over the short term, over a longer term it reverts to zero/small positive rate.

enter image description here

Now let's introduce the concept of a stationary series. A stationary series has a lot of properties, but to wrap your mind around it and at the risk of oversimplification, think of it as being a series that has a constant mean and a constant variance over time (ignore for now the other key property - covariances not depending on time). Looking again at the chart above, it is clear that the blue and orange lines do not have constant means, while the gray one seems to have a constant mean and constant variance over time. (Technically, stationarity refers to processes and the series are mere realizations of the process, but don't worry about this at this point).

You should conduct a formal test for stationarity and there are a host of tests out there. The three most popular are ADF, PP, and KPSS. ADF is a great tool but requires a lot of care in usage, because if it (the lags) is mis-specified, if will give invalid results. You asked for a clarification of the lags. Fortunately, you don't have to worry about it if you use the PP test instead of ADF. The PP test can be thought of as the ADF test that is robust to serial correlation (hence correct specification of lags is not crucial) and heteroskedasticity. It is a good idea to do the KPSS test as well, as it has the opposite null hypothesis, when compared to the PP test. The null hypothesis in the PP test is that the series is not stationary, so if you get a p-value below 0.05, you reject the null hypothesis and conclude that the series is stationary. It is the opposite with the KPSS test: null is that it is stationary.

If you conclude that your 2 series are not stationary, take the first difference of each and repeat the process for the first-differenced series. Concluding that your original series are not stationary while the first-differenced series are stationary amounts to saying that your original series, when differenced once, become stationary, hence they are what is referred to as Integrated of Order 1, or I(1). (If your series X is {10,8,15,11...} then your first differenced series (Xt-Xt-1) is {missing, -2,7,-4}, where -2=8-10, 7=15-8, and -4=11-15).

I will assume that your PP and KPSS tests suggested that both of your series are I(1). The next step is to regress one series on the other one, and save the residuals from this regression. This residual is itself a time series. If this residual series is stationary (use the same tests as you did above), then you conclude that the 2 variables are cointegrated, with the cointegration coefficient estimated to be the beta hat on the independent variable in the regression above.

What is the cointegration coefficient? In the case of the interest rates above, we said that they are cointegrated with a cointegration coefficient of 1. If T10y and T6m are the two interest rates, each of which is non-stationary, then a cointegration coefficient of 1 means that a new series T10y-1*T6m is stationary. If the cointegration coefficient was equal to 3 instead, then that would suggest that T10y-3*T6m is stationary. I hope this helps.

There is a second step to this Engle-Granger cointegration process, in which you build an Error Correction model using the cointegrated relationship, but from what I understand your interest is only in the first step above.

  • $\begingroup$ Thanks for the reply! I ran the data through an online calculator for this correlation and got a p value of ~0.30 which from my understanding says there isn't any relationship between the two $\endgroup$ Jan 25, 2019 at 1:08
  • $\begingroup$ How many observations do you have? $\endgroup$ Jan 25, 2019 at 1:25
  • $\begingroup$ In practise I will have between 50-75 $\endgroup$ Jan 25, 2019 at 1:32
  • $\begingroup$ My bad, having re-read your question, I believe you intend to treat these as time series. Then what you want to do is to do a cointegration analysis to see if these two series move together. To do so, you'll want to check to see if your series are stationary. If they are not, you'll need to make sure they are integrated of the same order. I'll assume they are each I(1). Regress one on the other and check if the residual is stationary. If residual is stationary, they are cointegrated. $\endgroup$ Jan 25, 2019 at 1:46
  • $\begingroup$ Explore these discussions stats.stackexchange.com/questions/18076/… stats.stackexchange.com/questions/130660/… $\endgroup$ Jan 25, 2019 at 1:56

I assume that when you say "correlation" you mean pearson's. What you could try is spearman's $\rho$ , which quantifies how monotonous the relationship between x and y is.

Another way of looking at it is doing Pearson's correlation on the ranks of the values.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.