[R-SIG-Finance] Simulate the stock market for back testing strategy ---R bootstrap function
Brian G. Peterson
brian at braverock.com
Sat Feb 9 16:49:50 CET 2008
Dirk Eddelbuettel wrote:
> On 9 February 2008 at 07:05, elton wang wrote:
> | Thanks for Brian's reply.
> | to make this more relevant to this list, what
> | functions in R can do bootstrap resampling while
> | keeping the autocorrelation in the original data? (I
> | only know function of sample()). Would this resmapled
> | data do any good on back testing?
>
> No.
>
> But any decent book on bootstrapping mentions the problem, and many theses
> and papers were (are ?) written on the issue. I haven't looked in a while,
> but 'block bootstrap' once was a popular idea for this. And an ad-hoc method
> I used five or six years ago for low-frequency (monthly) data was to sample
> in two stages
> first sample an integer (say between 1 and 6) to determine how 'large'
> a chunk I would fetch
> then sample an integer between 1 and N to determine where I pick the
> chunk from
> and re-constitute resample series this way. As I said, 'ad-hoc'. There are
> many other ways. But don't do just sample() as it is guaranteed to break
> any possible structure in the correlation your data.
A block bootstrap for time series is implemented in a slightly more
robust manner than that described by Dirk above in the function
tsbootstrap(tseries)
There are a number of other bootstrap methods available in package
"boot" and corresponding function "boot", but I haven't examined these
in detail for their tuning or applicability in time series.
I think I laid out some basic steps of building a trading model on
actual historical data in my prior email. Simulated data (via
resampling or any other method) after the point where you have a target
model is only a validator of the model, not the starting point, or
you're almost certain to get worthless results.
Regards,
- Brian
More information about the R-SIG-Finance
mailing list