Jan
13
Simulation, from Phil McDonnell
January 13, 2008 |
When working with spreadsheets and random numbers there are some techniques which can be helpful. For example suppose we used the real data of daily market changes but wished to randomly reorder them to see if the original order had different properties than the random order. We could perform 999 reorderings and compute some stat of interest for each reordering. Then sorting the 999 stats in order smallest to largest would give us a very nice table in which we could look up the p value of our stat of interest.
For example, suppose we wanted to test whether the recent trading ranges were wider than the should have been at random. We would take 999 reorderings and calculate the range for each. We then compare the range from the original empirical distribution to see where it falls in the sorted table of random ranges. If it is in the 50 it is too small at the 5% level (one tailed test). If it is in the top 50 it is too large for a 5% one tailed test. For a two tailed test we look for the bottom and top 25.
On an Excel spreadsheet if we use the RANDBETWEEN() function as an INDEX into the original table of numbers it will allow us to randomly sample from the original distribution to create our new random distribution. The VLOOKUP() function is often useful here as well. In R one can use the boot() function, from package boot, to do all the heavy lifting of randomization. Easier than trying to do it in a spreadsheet.
In my book Optimal Portfolio Modeling I recommend a slight variation on this technique. The usual technique is to randomize each day. The thinking behind this is that the low autocorrelation usually present in markets implies that there is little or no linear relationship between successive days in a time series. But this says nothing about any non-linear relationships — patterns, cycles, mean reversion, conditional heteroskedasticity and many others. To capture these (if they exist) we can take random blocks of time, such as 20 days. We would randomize the start time of the block. So if our random number picked day 31 as the random time we would use the block from day 31 to day 50 as the block. The idea is to splice together these random blocks to see if they behave differently from the original. Making the block length long relative to the granularity of the data (say 20:1) helps to preserve most of any putative non-linear behavior.
It is also instructive to compare the randomized daily design to the randomized 20 day block design. If there is a significant difference then something non-linear may be going on.
Comments
2 Comments so far
Archives
- May 2013
- April 2013
- March 2013
- February 2013
- January 2013
- December 2012
- November 2012
- October 2012
- September 2012
- August 2012
- July 2012
- June 2012
- May 2012
- April 2012
- March 2012
- February 2012
- January 2012
- December 2011
- November 2011
- October 2011
- September 2011
- August 2011
- July 2011
- June 2011
- May 2011
- April 2011
- March 2011
- February 2011
- January 2011
- December 2010
- November 2010
- October 2010
- September 2010
- August 2010
- July 2010
- June 2010
- May 2010
- April 2010
- March 2010
- February 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
- August 2006
- Older Archives
Resources & Links
- The Letters Prize
- Pre-2007 Victor Niederhoffer Posts
- Vic’s NYC Junto
- Reading List
- Programming in 60 Seconds
- The Objectivist Center
- Foundation for Economic Education
- Tigerchess
- Dick Sears' G.T. Index
- Pre-2007 Daily Speculations
- Laurel & Vics' Worldly Investor Articles
unfortunately this would be all descriptive, not predictive