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

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).

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.