normal_lpdf: Location parameter is nan, but must be finite!
I seem to be blind. I’m using code similar to this (my goal is something like BVAR, or a way to forecast five time series with a hierarchical element). The cmdstanr syntax check comes back fine, but then sampling fails—something about the mu line. What are the chances someone can see what I am missing and causing the above error?
I’ve read some of the other posts about this but haven’t been able to solve this with initializing the starting values, either, like drift and the sigmas starting at value 1.
(Bonus points if you help me resolve this too: “Declaration of arrays by placing brackets after a variable name is deprecated…”)
data {
int <lower = 0> N;
vector[N] pmpm;
vector[N] size;
}
parameters {
real <lower = 0> sig_obs;
real <lower = 0> sig_proc;
real drift;
}
transformed parameters {
real mu[N];
mu[1] = pmpm[1];
}
model {
drift ~ normal(0, 1);
sig_obs ~ exponential(10);
sig_proc ~ exponential(1);
for (i in 2:N) {
pmpm[i] ~ normal(mu[i], sig_proc / sqrt(size[i]));
mu[i] ~ normal(mu[i - 1] + drift, sig_obs / sqrt(size[i]));
}
}
The inputs are like this:
N
[1] 14
pmpm (centered and scaled)
[1] -0.36 1.13 0.42 -0.08 -1.11 -1.17 -0.71 -0.34 -1.16 -0.73 -0.06 1.01 1.86 1.31
size
[1] 526 559 570 564 551 520 530 580 615 652 668 649 636 581
Thank you.