MatthieuStigler / tsDyn

tsDyn
tsdyn.googlecode.com
GNU General Public License v2.0
34 stars 20 forks source link

TVAR.sim/boot: allow for external threshold variable `thVar` #46

Open MatthieuStigler opened 2 years ago

MatthieuStigler commented 2 years ago

Multiple users requested to have an external threshold in TVAR.sim. This is currently not possible, triggering message Cannot (yet) bootstrap model with external thVar or commonInter.

I won't have time to do this anytime soon, but here would some steps to follow:

library(tsDyn)
#> Registered S3 method overwritten by 'quantmod':
#>   method            from
#>   as.zoo.data.frame zoo

## works with internal thVar
tv <- TVAR(zeroyld, lag=2, nthresh=1, thDelay=1, trim=0.1, mTh=1, plot=FALSE)
#> Best unique threshold 10.653
head(TVAR.boot(tv),2)
#>      short.run long.run
#> [1,]     2.183    1.575
#> [2,]     2.246    1.545

## works with internal
tv_ext <- TVAR(zeroyld, lag=2, nthresh=1, thVar=rnorm(nrow(zeroyld)), plot=FALSE)
#> Best unique threshold -1.341946
TVAR.boot(tv_ext)
#> Error in TVAR.boot(tv_ext): Cannot (yet) bootstrap model with external thVar or commonInter

Created on 2022-10-16 by the reprex package (v2.0.1)