Hi, I am trying to run a simple hierarchical logistic regression model, but keep getting following error message:
"Syntax error in ‘string’, line 6, column 5 to column 6, parsing error:
Expected range constraint or identifier as part of top-level variable declaration."
I am not sure what the issue is, I thought that it may have something to do with the multiple indexing later in the model block and the variable subIdx in the data block. I tried applying different signatures (e.g. real subIdx[], or vector[] subIdx), but keep getting (different) error messages.
I would be really grateful if anyone could help me with this problem. Thank you!
data {
int<lower=0> N; //number of subjects
int<lower=0> Nx; //number of regressors
int<lower=0> Ntotal;
int[Ntotal]<lower=1> subIdx; //array containing subject ID per trial
real y[Ntotal];//LaterOptionChosen
real x[Ntotal, Nx];
}
// The parameters accepted by the model. Our model
// accepts two parameters 'mu' and 'sigma'.
parameters {
real beta0_mu; // intercept population level
real<lower=0> beta0_sigma; //variance population level
real xbeta_mu[Nx]; // regressor estimates
real <lower=0> xbeta_sigma[Nx];
real beta0_s[N];
real xbeta_s[N, Nx];
}
model {
beta0_mu ~ normal(0, 10000000); //prior intercept
beta0_sigma ~ uniform(0.0001, 100); //prior intercept error
for (j in 1:Nx) {
xbeta_mu[j] ~ normal(0, 10000000); //prior slope
xbeta_sigma[j] ~ uniform(0.0001, 100); //prior slope error
}
for (n in 1:N) {
beta0_s[n] ~ normal(beta0_mu, beta0_sigma);
for (j in 1:Nx) {
xbeta_s[n, j] ~ normal(xbeta_mu[j], xbeta_sigma[j]);
}
}
for (i in 1:Ntotal) {
real pr[i] = 1 / (1 + exp(-(beta0_s[subIdx[i]] + xbeta_s[subIdx[i], 1:Nx]*x[i, 1:Nx])));
y[i] ~ dbern(pr[i]);
}
}