Threshold Autoregression Stalled at Warmup

I am calling R from STAN to estimate a threshold autoregressive model which is piecewise autoregressive model that exhibits self-exciting regime changes. Also, I am incorporating Bayesian horseshoe priors on the autoregressive coefficients. When I go to posterior sampling using STAN, everything halts after the initial gradient evaluation, which took an unusual 0 seconds. I have attempted to reparameterize this model with a variety of changes. If you have any suggestions, that would be amazing.

Also, a common segfault error occurs in R when conducting a simulation study using STAN. If I conduct posterior sampling for 100 replications, I have to rerun the code after every 5-11 replications due to memory mapping errors. I’ve seen that this may be caused by the rstan option (auto_write=T). Also, when using parallelization for not only the chains but also the replications, I often get connection errors. This may be due to the uneven time needed across multiplie chains. I have done a lot of reading online regarding both of these errors

TAR1.stan (1.8 KB)

1 Like

Hmm, I had a look at the model. The “if” statement is the thing that stands out the most to me. This is like a changepoint model, I think? This is probably where I’d focus my efforts.

There’s an example in the manual of manually marginalizing out a discrete change point (Section 15.2 “Change Point Models” in the 2.16 manual).

I think I’ve seen in other places people replacing the hard if-statement with like a sigmoid sorta thing. So you slowly turn one thing off and another on.

It’s scary that the partial derivative of the log density with respect to thresh with that if statement in there could be zero, but then if thresh did move a non-infinitesimal amount, it might cause the density to change (from that if statement).

I don’t know what to do about that, haha

Thank you very much. The majority of my research involves smooth transition autoregressive models where a sigmoid function replaces the step function. I will look back at the STAN manual regarding change point models. I appreciate your response.

I’m afraid the model went over my head. For this:

I’d suggest opening a new topic in which you show what you’re doing in terms of commands and settings and platform (such as how much memory you have) along with the exact output you get. It’s much easier to heop that way than guessing.