dataSnoop {ttrTests}R Documentation

Two Tests for Data Snooping: RC and SPA

Description

Tests for data snooping bias by doing bootstrap resampling, then finding the best parameterization in the bootstrapped samples and performing one of two popular tests - White's Reality Check or Hansen's test for Superior Predictive Ability. Can write a summary of results to a file as a LaTeX figure.

Usage

dataSnoop(x, ttr = "macd4", start = 0, nSteps = 0, stepSize = 0, burn = 0, 
short = FALSE, condition = NULL, silent = TRUE, TC = 0.001, loud = TRUE, alpha = 0.025, begin = 1, 
percent = 1, file = "", benchmark = "hold", bSamples = 100, test="SPA",latex="")

Arguments

x A univariate series
ttr The TTR to be used. Can be a character string for built-in TTRs, or a user defined function whose output is a position series s(t). See 'defaults' for a list of built-in TTRs.
start Initial values for parameters
nSteps How many parameter choices to use for each parameter
stepSize The difference between successive choices of a parameter.
burn When computing the position function s(t), values for t < burn will be forced to 0, i.e. no position held during the 'burn' period
short Logical. If false the position function s(t) will be forced to 0 when it would otherwise be -1, i.e. no short selling
condition An extra opportunity to restrict the TTR so that position is forced to 0 under some condition. Must be a binary string of the same length as the data 'x'. See 'position' for more details.
silent Logical. If TRUE, supresses output from subroutines
TC Percentage used to compute returns adjusted for trading costs.
loud Logical. If FALSE, supresses output from the main function(s)
alpha Confidence level for 2-sided hypothesis testing
begin The starting index of the data. The function assumes that the user wants a subset of the data, where the default subset is the entire data
percent How much of the original data to use (default 100
file The full writable path string for a file to which output will be appended. Ideal for reviewing results.
benchmark When computing 'excess' returns, all functions in this package subtract the conditional returns based on a given "ttr" from the "benchmark" returns. Two different TTRs can be compared this way if desired.
bSamples Number of bootstrapped samples to analyze
test Supports "RC" which is White's Reality Check, or "SPA", which is Hansen's test for Superior Predictive Ability
latex Full path name for a writable file. The laTeX code that generates a figure with a summary of the output will be appended to file.

Value

Returns the P-value or values from the given test.

Note

See papers for details on the 'V' values an 'T' values

If p-value is significant, then the null hypothesis that good performance is due to data snooping is rejected. However, this does not preclude any other null hypothesis that might explain good results.

EXTREMELY IMPORTANT NOTE: The functions in this package evaluate past performance only. No warranty is made that the results of these tests should, or even can, be used to inform business decisions or make predictions of future events.

The author does not make any claim that any results will predict future performance. No such prediction is made, directly or implied, by the outputs of these function, and any attempt to use these function for such prediction is done solely at the risk of the end user.

Author(s)

David St John

References

Ryan Sullivan, Allan Timmermann, and Halbert White. Data snooping, technical trading rule performance, and the bootstrap. The Journal of Finance, 54(5):1647-1691, 1999.

Peter R. Hansen. A Test for Superior Predictive Ability. Jounal of Business and Economic Statistics, 2005.

Examples


spData <- as.vector(getYahooData("SPY",start="20060101",end="20081231")[,"Close"])
rc <- dataSnoop(spData,bSamples=3,test="RC")
## spa <- dataSnoop(spData,bSamples=3,test="SPA")


[Package ttrTests version 1.4 Index]