tsDyn icon indicating copy to clipboard operation
tsDyn copied to clipboard

TVAR.LRtest function is only working for "1vs" but not for "2vs3"

Open yasmine131119 opened this issue 2 years ago • 1 comments

I want to estimate a TVAR model that includes an external threshold variable but the TVAR.LRtest function is only working for "1vs" but not for "2vs3". #codes examples Y<- TVAR.LRtest(X , lag=2, trend=TRUE, thVar=diff(Z), thDelay=1, nboot=100, plot=FALSE, trim=0.15,test="2vs3") Error in if (round(z2[i - bestDelay], ndig) <= bestThresh) { : missing value where TRUE/FALSE needed

yasmine131119 avatar Apr 27 '23 10:04 yasmine131119

Hi Yasmine

Thanks for sharing the issue (though your example was neither minimum nor self-reproducible example, in the future see https://stackoverflow.com/help/minimal-reproducible-example), but here is a reprex confirming that you found a bug. I am quite busy so not sure when I will be able to fix it.

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

data(barry)
Y <- TVAR.LRtest(barry[,1:2], 
                thVar=barry[,3],
                plot=FALSE, test="1vs")
#> Warning: the thDelay values do not correspond to the univariate implementation in tsdyn

Y <- TVAR.LRtest(barry[,1:2], 
                thVar=barry[,3],
                plot=FALSE, test="2vs3")
#> Warning: the thDelay values do not correspond to the univariate implementation in tsdyn
#> Error in if (round(z2[i - bestDelay], ndig) <= bestThresh) {: missing value where TRUE/FALSE needed

Created on 2023-05-01 with reprex v2.0.2

MatthieuStigler avatar May 01 '23 10:05 MatthieuStigler