Hello guys I’m trying to run a model in Stan with the following specs. Everything works well. But when I add the generated quantities (y_pred) the model won’t compile and it does not check on RStudio (doesn’t give any error). Without the generated quantities it runs smoothly. X dimensions are 20095 by 4.
What am I doing wrong?
data {
int<lower=1> N; //the number of observations
int<lower=1> K; //number of columns in the model matrix
matrix[N, K] X; //the model matrix
vector[N] y; //the response variable
}
parameters {
real alpha; // intercept
vector[K] beta; // coefficients for predictors
real<lower=0> sigma; // error scale
}
model {
y ~ normal(alpha + X * beta, sigma); // likelihood
}
generated quantities {
vector[N] y_pred;
for (n in 1:N){
y_pred[n] = normal_rng(alpha + beta * X[n], sigma);
}
}
Thank you for your help