I have the following stan model, but it seems it works only when the ndose>1. Anyway I can work around this so the same model can handle both when ndose=1 and ndose>1?
Stan code:
data {
int<lower=0> ndose;
real doses[ndose];
int n[ndose];
int n_dlt[ndose];
vector[2] mprior; // prior for log_alpha and log_beta (blrm.stan model beta instead)
matrix[2,2] vprior;
}
parameters {
vector[2] lparam;
}
model {
// lparam ~ multi_normal(mprior, vprior);
for (i in 2:ndose){
target += binomial_logit_lpmf(n_dlt[i]|n[i], lparam[1] + exp(lparam[2])*log(doses[i]/doses[1]));
}
}
generated quantities{
real postprob[ndose];
for (i in 1:ndose){
postprob[i]= exp(lparam[1] + exp(lparam[2])*log(doses[i]/doses[1]))/(1+exp(lparam[1] + exp(lparam[2])*log(doses[i]/doses[1])));
}
}