1
$\begingroup$

How do i compare two time series:(Pearson correlation coefficient) 1st time series is generated by google trends for search term "India" 2nd time series is Foreign Tourist Arrivals(absolute value of arrivals) to India each month.

$\endgroup$
1
  • 1
    $\begingroup$ Are you sure you want a simple correlation? What kind of comparison do you want? What would you like to know about how they're related? Eg, do you want to know if values in 1 ts predict subsequent values in the other? Do you want to know if they are cointegrated? $\endgroup$ Commented Dec 1, 2015 at 22:03

1 Answer 1

1
$\begingroup$

The simple way to compute it is to pair up all observations at the same time and compute the sample Pearson's correlation (this is what Google Correlate does)

For example, Let's say you want to correlate the time series $S_1$ and $S_2$:

 time S_1     S_2
 t_1  20.4400 19.7450
 t_2  19.0750 20.3300
 t_3  20.0650 20.1700
 ..   ..      ..

Which might look like this when plotted:

enter image description here

You just have to use this formula: $$ r(S_1,S_2) \triangleq \frac{ \sum_{k=1}^n (S_1(t_k) - \bar{S_1})(S_2(t_k) - \bar{S_2}) }{ \sqrt{ \sum_{k=1}^n (S_1(t_k)- \bar{S_1})^2 \sum_{k=1}^n (S_2(t_k) - \bar{S_2})^2 }} $$ where $S_1(t_k)$ is a particular value of the time series $S_1$ at time $t_k$, and $\bar{S_1}$ is the average value of $S_1$.

(Just look at the formula of the sample Pearson's correlation between two variables $X$ and $Y$, from wikipedia)

As Gung said, there are different approaches to tackle this problem. Pearson's correlation is good if you are interested in linear correlations, which are very intuitive. There are other measures of dependencies which identify non-linear relationships. I can point you out to a presentation I prepared (hope it is not too shameful to add something of mine here)

$\endgroup$
3
  • $\begingroup$ Hey Simone, My hypothesis is to use google trends to improve traditional forecast of FTA to India . TO narrow down the search queries , i want to choose queries which are correlated to the monthly FTA time series. Additionally , How can we aggregate weekly google trends data to get monthly data. $\endgroup$
    – Nkhun
    Commented Dec 3, 2015 at 15:13
  • $\begingroup$ I think that averaging week values would work fine $\endgroup$
    – Simone
    Commented Dec 3, 2015 at 21:58
  • $\begingroup$ I really appreciate you posting your presentation. It's helpful, not promotional. $\endgroup$
    – SCallan
    Commented Feb 9, 2016 at 19:22

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.