My company makes widgets. We take a random sample of these widgets every month and count how many are good and bad. Some people think that we are worse at making widgets in the months where we make more - in other words, the months where we make more widgets have a higher proportion of bad widgets.

Is calculating the Pearson correlation coefficient between the number of widgets made in a month and the proportion of bad widgets (in the monthly sample) an appropriate way to check this theory?

I am unsure whether it is OK to use the Pearson correlation coefficient because the dataset is a time series.

I have data on the number of widgets made every month, the number of widgets sampled every month and the proportion of bad widgets found in the sample every month.

Example plot for 29 months

  • 1
    $\begingroup$ Computing the correlation might be "appropriate" in some sense, but why not use a much more informative procedure, such as plotting the proportion against the volume? Sometimes that settles the matter; and, when it doesn't, it provides useful information for selecting an appropriate statistical procedure. $\endgroup$ – whuber Jan 20 '19 at 20:53
  • $\begingroup$ Thanks. I have plotted the proportion against the volume. I would say there is a generally positive trend with considerable scatter. What sort of useful information could I get from the plot that would help me to select an appropriate statistical procedure? $\endgroup$ – Bobby1990 Jan 21 '19 at 7:39
  • 1
    $\begingroup$ Can you show us that plot? $\endgroup$ – kjetil b halvorsen Jan 21 '19 at 13:01
  • $\begingroup$ I have added an example plot showing similar data for 29 months. $\endgroup$ – Bobby1990 Jan 21 '19 at 18:05

The issue with using correlation measures for time series, is that one doesn't know whether those correlations are statistically significant or simply a function of time.

For instance, if one analyses the movement of oil and the S&P 500 index over a period of 50 years, one will generally find a strong correlation between the two series. However, this does not indicate that the movement is necessarily statistically significant - it simply means that the two series have trended upwards over time - as we would expect over the longer-term.

So, how can one determine whether a correlation is significant or due to chance? The way we can test for this is by determining if two time series are cointegrated.

A cointegrated pair is one where the movements between two time series are statistically significant, i.e. not simply due to chance. Imagine a drunk woman walking with her dog on a leash. The two might walk in opposite directions at times, but because the dog is on a leash, the woman and the dog will ultimately end up going in the same directions.

If you are using R, the coint.test available from the aTSA package is a good way of testing for cointegration using the Engle-Granger method.

Consider the following variables X and y:

X <- matrix(rnorm(200),100,2)
y <- 0.3*X[,1] + 1.2*X[,2] + rnorm(100)

A cointegration test is run for X and y:


Here are the generated results:

Response: y 
Input: X 
Number of inputs: 2 
Model: y ~ X + 1 
Engle-Granger Cointegration Test 
alternative: cointegrated 

Type 1: no trend 
    lag      EG p.value 
   4.00   -4.76    0.01 
 Type 2: linear trend 
    lag      EG p.value 
  4.000   0.555   0.100 
 Type 3: quadratic trend 
    lag      EG p.value 
    4.0    -1.9     0.1 
Note: p.value = 0.01 means p.value <= 0.01 
    : p.value = 0.10 means p.value >= 0.10

We can see that we have a p-value < 0.05 for type 1: no trend. However, the linear trend and quadratic trend are both statistically insignificant with a p-value > 0.05. In this regard, this indicates that no trend exists between the two time series, and they are not cointegrated.

If you have access to R, you might find the above of use in checking for the existence of cointegration between volume and proportion.

  • $\begingroup$ Michael, you state that a strong correlation "does not indicate that a movement in one 'causes' a movement in another". I just wanted to clarify that cointegration doesn't either. Cointegration merely establishes that two series tend to co-move for whatever reason. For causality, a structural VAR model in the tradition of Sims should be explored. $\endgroup$ – ColorStatistics Jan 21 '19 at 22:03
  • $\begingroup$ The OP phrased his question "we are worse at making widgets in the months where we make more" in a correlation sense so the cointegration analysis you suggested does the trick. Just wanted to clarify that fortunately the OP did not ask about causation, for in that case we'd have to do more than a cointegration test. $\endgroup$ – ColorStatistics Jan 21 '19 at 22:58
  • 1
    $\begingroup$ ColorStatistics, your first point makes sense - I was referring more to whether a movement is "statistically significant" or not. I have edited for clarify. You are also right in the sense that cointegration does not necessarily imply causation either. Rather, it is a better way of measuring the degree of correlation between time series models, since a standard correlation measure will be overly influenced by trends over time. $\endgroup$ – Michael Grogan Jan 22 '19 at 6:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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