# Follow the ants to richness

A friend of mine told me the secret of making money at the stock market. "It's easy", he said.

All I would have to do is to buy a big jar of ants. Then I should observe the ants movement on my kitchen table, while following the stock market.

I shall keep the ants which walk in line with the stock market and remove those who don't. Eventually I would have one ant left that walked all the way in line with the stock market.

Bingo! This is the one I have to keep feeding well and observe, as it clearly can predict the movements of the stock market.

For more complex problems I recommend to use animals with bigger brains.

1. Holger K. von Jouanne-Diedrich29 January 2013 at 09:51

This is the best illustration of data-snooping bias and overfitting I have seen so far: Perfect fit in-sample yet total failure out-of-sample!

2. I think it's nearly 1 Feb., not 1 April

3. have ants; will sell.

4. your code is cheating though: your super-ant is identically the movement of the market, instead of the 'best' ant of 100. *I want to know how big 100 has to be!* I don't have room for 10^8 ants in my kitchen.

5. also, if one uses your code to see how bad the 'super ant' is out of sample, they would come to the entirely wrong conclusion!

6. All you did is just MA(1), and it doesn't represent the markets since it is not Random walk.

Your friend did not provide you with a good model, market has auto regressive and GARCH is more appropriate for the market volatility...

Regards

7. make me re-think about modelling. Thanks.

8. haha, I think you're all missing the point however.

While it's great to be able to identify Mr Super Ant, what we really want to know is - where will he walk next? and, am I really happy living with this many ants in my kitchen?

Here's here the forecast package can help. It has an algorithm that will auto fit a timeseries forecast model. type the following after the script above:

install.packages("forecast")

library(forecast)

plot(forecast(stocks,level=c(0.25,0.5,0.75),h=10),main="Super Ant Marches Forth!!")

hence we see where he'll walk in the next ten days about 50% of the time (i.e. IQR in the dark blue band).

this also allows us to dispose of Super Ant himself and rid our kitchen of pests...

9. Thanks David,
One line of R code and I know the future!

Absolutely brilliant.
Cheers
Markus