I am completely new to Stan, so sorry for my standard questions. I am building a bayesian multi-level time series model and the code below is the start of my project. However, when I want to run it I get the error message: Unknown variable: vector variable “vector” does not exist. This is at line 66 in the model part for vector[H] beta;. I don’t know what I did wrong. Can someone help me with this error? Thanks in advance!
data {
int<lower=0> N; // Observations
int<lower=0> Npreds;
int<lower=0> H; // persons
int<lower=0> id[N]; // ID variable
real y[N]; // Y Vector
matrix [N, Npreds] x;
}
parameters {
real beta[H];
matrix [H, Npreds] gamma;
real gamma1;
real gamma2;
real<lower=0> y_sig; // regression variance
}
model {
//Priors
y_sig~uniform(0,1000);
vector[H] beta;
for(h in 1:H)
beta[h] = gamma1 + gamma2*col(x,1)[h];
// Likelihood
for(n in 1:N)
y[n] ~ normal(row(beta, id[n]) * row(x,n)', y_sig);
}
Another question I have is regarding the brms package in R. Does anyone know whether you could also fit models with a panel structure (multiple individuals over time) with it? I can’t find anything about it.