Dear All! I would like to ask a question. How to implement the following model in Stan?
I have a time-series:
y_t = \mu_t + \xi_t J_t + \epsilon_t, \qquad \epsilon_t \sim \mathcal{N}(0,\exp(h_t/2)).
I have no problem with modelling the SV part and \mu_t, but I do not understand how to incorporate a jump component. Ideally, I would like to have the following specification:
\xi_t \sim \mathcal{N}(0, \sigma_{\xi}^2) - measures the intensity of the jump.
J_t = \Phi(\lambda_0 + \lambda_x X) - determines the probability of the jump, where X is observable data that gives me information about the probability of the jump. If I use
bernoulli(Phi_approx(lam_1 + lam_x * x));
I receive an error:
Ill-typed arguments to ‘~’ statement. No distribution ‘bernoulli’ was found with the correct signature.
Because Stan does not support discrete parameter. Could you please suggest how to translate the model in Stan model or propose a similar model that could be implemented in Stan? Below, I provide a code that I wrote so far, but as I wrote before it does not match the structure exactly
data {
int<lower=0> T_len; // Number of observations
vector[T_len] y; // Time series data
vector[T_len] x; // Time series data
}
parameters {
vector[T_len] xi; // jump magnitude at time t
real<lower=0> sig_y; // Standard deviation of the y process
real<lower=0> sig_xi; // Standard deviation of the jump magnitude
real gamma_y; // Intercept of the y process
real lam_1; // Parameters for jump
real lam_x; // Parameters for jump
}
transformed parameters {
vector[T_len] jump = Phi_approx(lam_1 + lam_x * x); // Jump index at time t
}
model {
// Prior
sig_y ~ cauchy(0, 5); // Prior on the standard deviation of the y process
sig_xi ~ cauchy(0, 5); // Prior on the standard deviation of the jump magnitude
gamma_y ~ normal(0, 10); // Prior on the intercept of the y process
lam_1 ~ normal(0, 10); // Prior on the intercept of the y process
lam_x ~ normal(0, 10); // Prior on the intercept of the y process
xi ~ normal(0, sig_xi * jump); // Jump magnitude at time t
// Likelihood (speed up)
y ~ normal(gamma_y + xi, sig_y); // Likelihood of the data given
}
Thank you very much!
Best,
Borys