data{
real<lower=0> rt[1058];
int<lower=1,upper=2> ttype[1058];
int<lower=8, upper=20> setSize[1058];
}
parameters{
real<lower=0> saillance[2];
real sigma;
real tempsItems;
real t0;
}
model{
// Local variables
vector[21]K[2,20];
real Temp[2,20,21,21];
real P[2,20];
real nItemsInspect[1058];
int nII[1058];
int z[3];
z[1]<-8;
z[2]<-14;
z[3]<-20;
//Prior
for (s in 1:2){
saillance[s] ~ exponential(1);
}
sigma ~ uniform(0,1000);
tempsItems ~ normal(88, .01);
t0 ~ uniform(10, 1000);
for (c in 1:2){
for(N in 1:20) { // 20 is the max number of items in this experiment.
P[c, N] <- saillance[c] / (N-1+saillance[c]);
}
}
for (c in 1:2){
for (N in z[1]:z[3]){
K[c, N, 1] <- P[c, N];
for (k in 2:N){
for (i in 1:(k-1)) {
Temp[c, N, k, i] <- 1-P[c, N-i+1];
}
for (j in k:20){
Temp[c, N, k, j] <- 1;
}
K[c, N, k] <- P[c, N-k+1] * prod(Temp[c,N,k,]);
}
for (l in (N+1):21){
K[c, N, l] <- 0;
}
}
}
for (i in 1:1058){
nII[i] ~ categorical(K[ttype[i],setSize[i]]);
nItemsInspect[i] <- nII[i] * tempsItems +t0;
rt[i] ~ normal(nItemsInspect[i], sigma); //check
}
}