4
$\begingroup$

Apologies for this vague and unclear question, I have no background in statistics.

I have two vectors of time series data, covering a six month period. The data is in daily intervals (except for weekends).

The first vector contains the stock volume for a company on each of the days. The second vector contains an external volume variable (the number of Google searches) taken on the same date.

Figure

As visible on the graph above, (which is out of scale etc.) there is some type of relationship between the two.

I want to model the two time series as to predict a future stock volume values.

So far I have briefly looked into:

  • support vector machines for regression: but when I plotted the data on a scatter graph there isn't any clear relationship, so this made me think that the SVM approach would fail.

  • time series analysis: this approach confused me because there isn't any obvious trends in the data

Can anyone offer any advice on what I approach I should take?

$\endgroup$
  • $\begingroup$ In the sentence "I want to model the two time series as to predict a future values of $X$", what is $X$? Is that one of the two time series or is this a third variable? $\endgroup$ – Macro Aug 16 '11 at 15:12
  • $\begingroup$ @Macro, apologies, I want to predict future values of the first vector, the stock volume. $\endgroup$ – S0rin Aug 16 '11 at 15:53
  • $\begingroup$ Is this really a rephrasing of your previous question at stats.stackexchange.com/questions/14237/…? $\endgroup$ – whuber Aug 16 '11 at 16:11
  • $\begingroup$ @whuber, I think not. The purpose of that question is/was about normalisation, specifically how to normalise stock volume. The purpose of this question is to get feedback on how to model the actual data, which is displayed on the above graph. $\endgroup$ – S0rin Aug 16 '11 at 16:16
12
$\begingroup$

You can learn a lot by exploring the temporal relationships among the data before setting off on more sophisticated methods of time series analysis.

Because the image does not provide a horizontal scale, I have used an artificial one (pixel coordinates of the image columns). I have freely rescaled the two plots and placed the activity at zero, which is likely what its minimum is:

Data

(There's a tiny problem where the two graphs originally overlapped, but that won't affect the analysis.)

Because you're looking for a potential causal effect of activity (red) on volume (blue), plot the forward cross-correlation function. This simply computes the correlation of the activity[1..n+1-k] and volume[k..n] as a function of k (the "lag"). My first pass at this found--as one would expect--that the extreme activity peak has a lot of leverage, so I went back and used the logarithm of 1+activity instead. Here's the cross-correlation:

Cross-correlation plot

It reaches a definite peak at a lag of k=20. (The peak using the untransformed activities was at k=18, essentially the same.) To better see what's going on, look at the scatterplot of activity[1..n+1-20] against volume[20..n]:

Scatterplot at lag 20

That is, each log activity value (x) is plotted against the volume after 20 units of time have elapsed (y). (The points are colored according to time. This is really a 3D plot with time as the z coordinate, looked at from high above. 3D manipulations make the patterns clearer.)

This scatterplot makes it evident that the relatively high correlation at this lag (about 0.40 according to the preceding plot) is due entirely to the activity peak at time 220 being followed by the volume peak at time 220+20 (as followed by a plunge shortly thereafter). Everything else looks like random wandering. This tells us that there may be less than meets the eye: the appearance of a temporal relationship between these two series is caused by a single event and its aftermath; it does not appear to be a general association.

In effect, you may have one observation of a high activity followed after a certain short time by a spike in volume. Was this a coincidence or (hopefully) evidence of a pattern? It's impossible to tell. Additional data might bear out this generalization or might falsify it. Regardless, cross-correlation plots and lagged scatterplots are powerful and useful tools to evaluate the relationships.

$\endgroup$
  • $\begingroup$ "(pixel coordinates of the image columns)" i've heard of this, what software did you use to achieve that? $\endgroup$ – user603 Aug 16 '11 at 18:39
  • $\begingroup$ @user Mathematica 8. It can import an image as an array of (r,g,b,a) values. I used it to select the row indexes of all such values that were predominantly red (resp. blue) in each column (after trimming off the legend), then averaged those and plotted the results to verify. Where blue values were missing (the red curve crosses over the blue), I substituted red values. This approach was possible because each time series appears as a distinct functional graph: only one value in each column. $\endgroup$ – whuber Aug 16 '11 at 18:51
  • $\begingroup$ @whuber, thank you so much for the detailed answer. It is much appreciated. I'm taking my time to try and understand it all. $\endgroup$ – S0rin Aug 18 '11 at 9:51
  • $\begingroup$ @Moom If you need details, examples, or clarification, ask away: our objective on this site is to create great answers by using the community to improve what we have. $\endgroup$ – whuber Aug 18 '11 at 15:24
  • 1
    $\begingroup$ @Lepidopterist Yes, the log was a quick and dirty way of reducing the leverage of extremely high values. The colors are explained directly beneath the graphic: "The points are colored according to time... ." This particular sequence of colors was a terrible choice, because it does not clearly indicate the times, but at least the colors help the eye discriminate groups of data within narrower time ranges. They demonstrate that the excursions beyond log activities of 4 and below volumes of 250 occurred during the same narrow period. $\endgroup$ – whuber Mar 19 '17 at 20:55
1
$\begingroup$

What do you want to do : - Make forecasting of each of the time serie independently? - Make forecasting of one time series and then determine the values of the other one?

In any case this reference will help you a lot : http://www.sciencedirect.com/science/article/pii/S0169207006000021

What is the length of your time series (meaning how much data do you have)? What is the horizon of forecasting (meaning do you want to make 1 day, 1 month or 1 year ahead prediction)?

By looking at your data, I would say that there is no obvious trend of seasonality, to look at a longer time series would help to be sure, to see if there's any seasonality or trend, plot the autocorrelation function (you can find lot of stuff about it).

For both of your time series, they look like a random walk except maybe for the peak, it depend of what you want to model. If you're interested of modeling the right amount of peak in your data without being precise on the other value beetween the peak, use a count process (poisson process) or maybe a threshold model. If you want to model the other value, then autoregressive model could be a solution.

You can use time series analysis even if there is no trend in your data. Support Vector Machine are maybe a little too complex for the kind of time series you have, but it could be an interesting to dig into it, if you have time to spend on it.

$\endgroup$
  • $\begingroup$ thanks for the response. I just want to predict the stock volume one day in advance. I have six months data, however, the stock volume time series does't have weekend data. I'll look into the count process (poisson process) and threshold models. $\endgroup$ – S0rin Aug 16 '11 at 15:54
1
$\begingroup$

You're trying to predict what, future volume? Is this a market impact model or something?

If you're trying to predict volume, time series analysis is likely your friend. This would basically be running an autoregressive model, i.e. a linear regression where the $x_{ij}$ are changes in volume ($j=0$) and Google searches ($j=1$) and the $y_i$ are future changes.

As for SVMs, an ordinary linear SVM might not be the best bet; check out kernel SVMs, which transform the data in various ways to elucidate relationships that would otherwise not be linearly separable. This could be helpful for dealing with any nonlinearities in your data, which definitely occur in financial data sets.

If you're actually intending to predict future price change, the KSVMs are likely the way to go, since predicting returns is extremely difficult and I could imagine many of the most useful aspects of the data would involve extreme values, i.e. nonlinearities.

If you're actually predicting volume/market impact/slippage, time series analysis is the most standard way to go.

$\endgroup$
  • $\begingroup$ I am only trying to model and then predict stock volume, preferably by a day. I'll look into time series analysis again. Thanks. $\endgroup$ – S0rin Aug 16 '11 at 16:04
  • $\begingroup$ Would this be a Vector AutoRegressive model? $\endgroup$ – S0rin Aug 16 '11 at 17:03
  • $\begingroup$ Yes, but with fixed coefficients. $\endgroup$ – William Aug 16 '11 at 20:20

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.