I have built a model in R that predicts weekly and monthly returns of stock prices using regression trees, roughly based on https://www.r-bloggers.com/using-cart-for-stock-market-forecasting/. In my training and test sets weekly and monthly return rates (the target variables) are calculated for Fridays as follows:

  • Weekly: (Friday close - Monday open) / Monday open
  • Monthly: (Last Friday of the month close - first Monday of the month open) / first Monday of the month open

Weekly returns are available for each Friday of the week and monthly returns are available for each last Friday of the month.

Using the predictive model, I can then predict weekly and monthly returns using the data available today. E.g. if today's data is xyz then the model predicts a weekly return of 0.1 and a monthly return of -0.02.

df_test$pred_weekly_return <- predict(tree_weekly,df_test)
df_test$pred_monthly_return <- predict(tree_monthly,df_test)

I am struggling with how to interpret these predicted weekly and monthly returns. If I use today's Wednesday 14 December data, is the predicted weekly return then for next week Wednesday 21 December or for this week Friday 16 December? And is the predicted monthly return then for the end of this month 31 December or, say, 31 days from now 13 January?

Any advice would be greatly appreciated.

  • $\begingroup$ Could you publish the code you are using? Thank you $\endgroup$ – vonjd Mar 10 '18 at 9:09
  • 1
    $\begingroup$ I'm voting to close this question as off-topic because it was crossposted to CrossValidated and has an accepted answer there. $\endgroup$ – Bob Jansen Mar 10 '18 at 10:15

It depends on the structure of your model. Unless the variables of your regression tree are lagged, you are going to be predicting the the weekly returns/monthly returns at time t.

Try an equation of the form (this would mean lagging all of your variables by 1 time period and training on the returns that way).

$y_t$= $B_{0_t}$ + $B_{1_{t-1}}$ $x_{1_{t-1}}$+ .... $B_{n_{t-1}}$ $x_{n_{t-1}}$

  • $\begingroup$ Thank you for this solution. I see that lagging variables as you suggest could work. On stats.stackexchange.com I was explained how to calculate forward periodic returns which solves the problem as well (stats.stackexchange.com/questions/251586/…). $\endgroup$ – aju_k Dec 15 '16 at 7:52
  • $\begingroup$ @aju_k: Crosspostings are being frowned upon. $\endgroup$ – vonjd Mar 10 '18 at 9:52

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