MatthieuStigler / tsDyn

tsDyn
tsdyn.googlecode.com
34 stars 20 forks source link

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

Open yasmine131119 opened 1 year ago

yasmine131119 commented 1 year ago

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

MatthieuStigler commented 1 year ago

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