Getting variable does not exist error, although the variable has defined

Hi ,

My stan code looks like this. I have defined the parameters in matrix form .

data {
int<lower=1> N;
int<lower=1> N1;
  int<lower=1> N2;
  int<lower=1> N11;
  int<lower=1> w;
  int<lower=0,upper=1> y[N];
  int<lower=1> K1; 
  matrix[N,K1] x11;
  //matrix[N2,K1] x2;

parameters {

  vector[w] alpha1;
  matrix[K1,w] beta1;
  vector <lower=0> [w] lambda;

model {

  vector[N] mu1;
  for(i in 1:N1){
   mu1[i] = alpha1[1]+ x11[i,] * beta1[,1];
  for(i in N11:N){
    mu1[i] = alpha1[2]+ x11[i,] * beta1[,2];
       for(k in 1:w){
target +=normal_lpdf(beta1[,k]| 0,1/lambda[k]);
target +=normal_lpdf(alpha1[k]| 0,10);

   target +=  cauchy_lpdf(lambda[1]|0,1);
   target +=  cauchy_lpdf(lambda[2]|0,1);

  for(i in 1:N1){
  target += bernoulli_logit_lpmf(y[i] | mu1[i]);  
   for(i in N11:N){
  target += bernoulli_logit_lpmf(y[i] | mu1[i]);  
However I got this error:


I double checked the code but  I have defined the variable "x11" in the code. I keep getting this error.

Can anyone help me to fix this?

The error is saying that x11 isn’t present in the data that is being passed to Stan, so you’ll need to check your data

@andrjohns got it thank you. Is there any better way to provide prior distributions when the parameters defined as a matrix/vector like in my example?