I am trying to use Stan to generate some data and Z is supposed to be an indicator matrix. I am receiving the following error message “No matches for : discrete_range_rng(int, int)
Function discrete_range_rng not found.”
data {
int<lower = 1> N; // Number of observations.
int<lower = 1> q; // Number of responses.
int<lower = 1> m; // Number of random effects.
int<lower = 1> I; // Number of observation-level covariates.
int<lower = 1> qN; // Number of total observations.
int<lower = 1> qm; // Number of total random effects.
}
generated quantities {
int j=1;
int<lower = 1> ind;
int<lower = 1> ind2;
matrix[qN,qm] Z;
while(j <= qN-1){
ind= discrete_range_rng(1,m)
ind2= discrete_range_rng(1,m)
Z[j,ind]= 1
Z[j+1,ind2]= 1
Z[j+1,ind]= 0
j=j+2
}
}
This is my R code which do what I want I want to use stan generate my data
Z ← matrix(0,responsestudents,teachersresponse)
j=1
while(j <= responsestudents-1){
ind ← sample(teachersresponse,1,rep=F)
ind2 ← sample(teachers*response,1,rep=F)
Z[j,ind] ← 1
Z[j+1,ind2] ← 1
Z[j+1,ind] ← 0
j=j+2
}