# "PARSER EXPECTED" when defining paramaters for model

I have 3 parameters and a list of covariates.

data {
...
vector[J] COV;       //altitude covariates
}

parameter {
real alpha;
real delta;
real<lower=0> gamma;
}


One of the parameters (gamma) I want to keep positive.

Then in my model I code:

model {
for (i in 1:J) {
gamma[i] ~ alpha + beta *COV[i];
xi[i] ~ beta(gamma[i],5);
}
}


I get the error “PARSER EXPECTED”.

How do I correctly input the mathematical formulation:

\gamma_i = \alpha + \delta \times COV_i \quad \text{for} \quad \gamma_i > 0

\xi_i = Beta(\gamma_i,5)

Can you post the entire error?

You’re attempting to index elements of gamma (gamma[i]), but you’ve declared gamma as a single real:

real<lower=0> gamma;


I’m guessing you want gamma to be a vector here:

vector<lower=0>[J] gamma;


You shouldn’t be using the tilde here (“~”). Tilde suggests that the statement relates to a likelihood or a prior probability. However, you simply intend to define gamma, for which you should use “=”:

`gamma[i] = alpha + beta *COV[i];"

Also, this means that gamma should be either a local parameter/variable in the model block or, or a transformed parameter in the transformed parameters block. It should no be defined in the parameter block. Only alpha and beta are parameters that need to be estimated. Gamma is derived from that

1 Like