Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SETAR predict not working with "none" #43

Open
Fatafim opened this issue May 29, 2022 · 3 comments
Open

SETAR predict not working with "none" #43

Fatafim opened this issue May 29, 2022 · 3 comments
Assignees
Labels

Comments

@Fatafim
Copy link

Fatafim commented May 29, 2022

Hello!
The case is pretty simple. Say I define a simple SETAR model:

set <- setar(training, m=1, nthresh = 1, include = "const")
and then I'm trying to calculate a prediction from that:
> predict(set, n.ahead = 1) Time Series: Start = 80 End = 80 Frequency = 1 [1] -1.083009
everything works just fine. However the same code with include="none":

set <- setar(training, m=1, nthresh = 1, include = "none")
predict(set, n.ahead = 1)
Time Series:
Start = 80
End = 80
Frequency = 1
[1] NaN

I really don't think it's the fault of the data (this error has been occurring to me multiple times on different datasets) so if I'm not doing anything wrong (am I?) I think that this is a bug that will need some attention.

Hope you have a nice day!


PS: the dataset I'm using is the datasets::lynx

@MatthieuStigler
Copy link
Owner

Bug confirmed (see reprex below), thanks for the report!

library(tsDyn)
#> Registered S3 method overwritten by 'quantmod':
#>   method            from
#>   as.zoo.data.frame zoo
x <- log(lynx)
set2 <- setar(x, m=1, nthresh = 1, include = "none")
#> Warning: Possible unit root in the low regime. Roots are: 0.9646
predict(set2)
#> Time Series:
#> Start = 1935 
#> End = 1935 
#> Frequency = 1 
#> [1] NaN

Created on 2022-05-30 by the reprex package (v2.0.1)

@Fatafim
Copy link
Author

Fatafim commented May 30, 2022

You're welcome! Any chance for a quick update?

@MatthieuStigler
Copy link
Owner

I am afraid not, as I have very little bandwidth currently, and the issue is bigger than I thought: the current code uses the old oneStep, while it should use setar.gen.

If you need the code sooner, you can just see how predict.TVAR uses TVAR.gen (likewise for predict.VAR and VAR.gen), to adapt it to predicta setar model. Literally all you have to do is to feed in the correct initial values and decide on which innovations to use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants