2
$\begingroup$

I want to see if a change in the volume of Google searches of a company affects that company's stock price. I have time series data from Google Trends and daily close price of the stocks in question, and I was thinking of doing the following:

Take daily percentage changes for both data sets, find correlation between Google search volume (x) and stock price (y), regress y on x.

I understand that correlation does not imply causality, but am I on the right track or should I be taking a different approach? I have some basic statistics knowledge but a relative beginner when it comes to time series data. Thank you!

$\endgroup$

3 Answers 3

1
$\begingroup$

Causality in times series is a very challenging topic and is not as simple as applying some filter or adding lags to justify causal statements. The most widely used and quite simple notation of causality in time series is Granger causality, see http://www.scholarpedia.org/article/Granger_causality, which is close to what you wanted to do in the first place.

There are some more sophisticated methods e.g. potential outcome approach extended to dependent data by [1], but if you are looking for something simple, I would rely on Granger. You could also test if $x$ forecasts $y$ out-of-sample, which could further improve your arguments.

Refs

[1] Bojinov, I., & Shephard, N. (2019). Time series experiments and causal estimands: exact randomization tests and trading. Journal of the American Statistical Association, 1-36. link: https://www.tandfonline.com/doi/full/10.1080/01621459.2018.1527225

$\endgroup$
6
  • $\begingroup$ Also Granger causality, is less about theories of causation, and more about prediction. $\endgroup$
    – Alexis
    Commented Apr 28, 2023 at 16:12
  • $\begingroup$ as in any causal analysis, it depends on the causal structure one is willing to assume. your last statement is, the very least, imprecise. Lastly, cross-mapping, like Granger, depends on the underlying causal mechanism. $\endgroup$ Commented May 9, 2023 at 14:30
  • $\begingroup$ I think we agree that assumptions about causal structures are important (and Sugihara & Co. eschew this in their methods). Do you have a good recommendation for a nuanced philosophical take about Granger causality and prediction vs structural causal modeling? $\endgroup$
    – Alexis
    Commented May 10, 2023 at 14:33
  • $\begingroup$ I think first and foremost it starts with the hypothesis. Whether stock prices are caused by Google trends, in a structural sense, or not, well, not sure it would be meaningful to analyse. Granger causality would marely check for predictive relationship. $\endgroup$ Commented May 17, 2023 at 20:26
0
$\begingroup$

There are two assumptions underlying the significance test associated with a Pearson correlation coefficient between two variables. Assumption 1: The variables are bivariately normally distributed. ... The significance test for a Pearson correlation coefficient is not robust to violations of the independence assumption. See course material here http://oak.ucc.nau.edu/rh232/courses/eps525/handouts/pearson%20correlation%20coefficient%20-%20handout.doc

Rather than simply focus on the correlation coefficient http://www.math.mcgill.ca/dstephens/OldCourses/204-2007/Handouts/Yule1926.pdf (possibly flawed by both anomalies and the need for lag structure or differencing in either Y or X ) focus on the strength of regression structure between the two series after you have accounted for arima structure and any latent deterministic structure such as pulses, level/step shifts , seasonal pulses and or local time trends.

as @LiKao wrote one needs to account (adjust) for previous values.

$\endgroup$
3
  • $\begingroup$ Did you post this answer in the right thread? Because the present question refers to regression rather than a test of Pearson correlation, this answer looks out of place. $\endgroup$
    – whuber
    Commented Mar 3, 2020 at 13:03
  • 1
    $\begingroup$ The OP stated " Take daily percentage changes for both data sets, find correlation between Google search volume (x) and stock price (y) " ( using the Pearson correlation ) and I was reflecting on how this might NOT be such a good idea, $\endgroup$
    – IrishStat
    Commented Mar 3, 2020 at 13:27
  • 1
    $\begingroup$ It's important to read and quote a question in full: you omitted the key codicil, "regress y on x." That clarifies what the OP means by "correlation," too. $\endgroup$
    – whuber
    Commented Mar 3, 2020 at 13:44
0
$\begingroup$

While your idea might give you some initial indication about a relationship, there is a lot to be careful about here:

  1. Stock prices (just like any time series) often depend on the stock price on the previous day. So if you leave out this variable, you are leaving out a lot of information of your model that should be in there. Essentially putting in stock prices from previous days is a common method in time series modeling (have a look at AR and ARIMA models).
  2. There may be some lag between the number of searches and the time it takes for those to affect the stock prices. So if you just put in the search data at day X and the stock price on the same day, you are limiting your model to strongly. It is better to also include number of searches on previous days.
  3. The more previous days you include, the more your model is bound to also give false positive results. You should include some method to constrain the influence of previous days (intuitively: the longer back the search data, the less likely it is to influence the stock prices). You can either do this in a Bayesian setting (set more constrained priors to previous data) or by using L1 or L2 regularization (with higher regularization the further back the data is taken).
  4. There are a number of packets you could use. Here is one in pymc3. You can find more examples here, under "time series".
$\endgroup$

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.