I’m trying to fit two AR(1) latent state variables using one time series.
c_t = \mu + s_t + l_t + \sigma_g \varepsilon_{g,t}
where
s_t = \rho_s s_{t-1} + \sigma_s \varepsilon_t
and
l_t = \rho_l l_{t-1} - sigma_l \varepsilon_{z,t}
where both shocks s_t and l_t are inversely affected by the same noise term (\varepsilon_t). Coding this up gives me the following STAN model:
data {
int<lower=0> T;
vector[T] c_t;
}
parameters {
// Growth rate hyper parameters
real mu;
real<lower=0> sigma_g;
// Disaster effect hyper-parameters
real<lower=0> sigma_s;
real<lower=0> sigma_l;
real<lower=0, upper=1> rho_s;
real<lower=0, upper=1> rho_l;
}
model {
// Define the latent variable and noise vectors
vector[T] s_t;
vector[T] l_t;
vector[T] eps_t;
// *** Model ***
s_t[1] = sigma_s * eps_t[1];
l_t[1] = -sigma_l * eps_t[1];
for (t in 2:T) {
s_t[t] = rho_s * s_t[t-1] + sigma_s * eps_t[t];
l_t[t] = rho_l * l_t[t-1] - sigma_l * eps_t[t];
c_t[t] ~ normal(mu + s_t[t] + l_t[t], sigma_g);
}
// Shocks
eps_t ~ normal(0, 1);
// *** Priors ***
mu ~ normal(0,2);
sigma_g ~ cauchy(0, 2.5);
sigma_s ~ cauchy(0, 2.5);
sigma_l ~ cauchy(0, 2.5);
rho_s ~ normal(0.5, 0.5);
rho_l ~ normal(0.5, 0.5);
}
Which yields a RuntimeError:
"RuntimeError: Exception during call to services function: `ValueError(“Initialization failed. Rejecting initial value: Error evaluating the log probability at the initial value. Exception: normal_lpdf: Location parameter is nan, but must be finite!”
From what I read on this forum, this could be solved by defining bounds when initializing my variables. I have done this insofar as possible. What could be driving this problem? I don’t see where this trivial model would be undefined for the parameters given.