Skip to content

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

@MatthieuStigler

Description

@MatthieuStigler

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:

  • tsDyn:::TVAR.gen has thVar but uses z2 ( as in if (round(z2[i - thDelay], round_digits) <= Thresh[1])), so need to replace
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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions