I was playing around with creating some lags and difference variables in the Transformed Data block. I had accidentally set the dimension on one of the transformed variables to a variable also defined in the transformed data block instead of making the calculation directly. It was quite difficult to figure out what was causing the problem as the output wasn't telling me what line to look at. For instance it would say
Error : error in call to assign; require matching dimensions, but found arg1(rows=0,cols=1); arg2(rows=527,cols=1)
failed to create the sampler; sampling not done
It might be helpful to make it more clear what line is generating these errors.
The correct code is below (just the data and transformed data blocks at least). To make the above show up, you would change the vector[T - P] to vector[T_P].
data {
int<lower=0> T;
int<lower=0> N;
vector[T] Y[N];
int<lower=1, upper=T> P;
}
transformed data {
int<lower=0> T_P;
vector[T - 1] Y_[N];
vector[T - P] Y_lag[N];
vector[T - P] Y_diff[N];
T_P <- T - P;
for (n in 1:N) {
Y_[n] <- tail(Y[n], T_P);
Y_lag[n] <- tail(head(Y[n], T - 1), T_P);
Y_diff[n] <- Y_[n] - Y_lag[n];
}
}