Unexpected dimension mismatch for integer vector in data initialization

Despite various coding attempts forum searches, and therapy sessions with my rubber ducky, I am stumped. I must be missing a basic concept. Any suggestions would be greatly appreciated.

Problem: I prepare a simple data list that includes an integer vector “i” containing 288 integer values. My simple Stan code compiles OK. When I sample (using this data list), I always get the same error message “Exception: mismatch in number dimensions declared and found in context; processing stage=data initialization; variable name=i; dims declared=(288); dims found=()”. I’ve tried sending the data as a data frame, and various functions to modify the type of “i” - always with the same result.

The code below ought to reproduce this odd behavior.

My R code (Windows 7, RStudio ver 1.2.1335, R ver 3.6.0, rstan ver 2.18.2)

dataList = list(   i=rep(1:24,each=12),   Y=rnorm(288,0,1) )
comp_dgp <- stan_model('C:/!/Bob - Pharmatech/recd 5-23-2019/play with i.stan')
fit_model <- sampling(comp_dgp, data = dataList, seed = 123)

My Stan code (play with i.stan):
note i is not used in this simple code. The plan is to use it to index vectors and matrices

data {
  int<lower=1> i[288]; 
  vector[288] Y;            
}
parameters {
  real <lower=0> sigma;
}
model {
  Y ~ normal(0,sigma);
}

Thanks in advance for any thoughts or suggestions!!

Dave

I can’t explain why, but try using a variable name other than i.

See https://github.com/stan-dev/rstan/issues/654

Eureka!! Thanks aornugent!! :-)

Thanks, Dave

Thanks Ari. The fault is not in our stars. It is with “i”. :-)

Thanks, Dave