I am trying to fit a multi-logit regression using categorical_logit(). I have read the example in the documentation (https://mc-stan.org/docs/2_20/stan-users-guide/multi-logit-section.html) but instead of reading in my regressors as a matrix I have input them individually because I want to transform them. However, I get the error “No matches for available argument signatures for categorical_logit: Real return type required for probability function.” I am not sure how to alter the format of my input to categorical_logit () while maintaining the variable transformation. Any advice is appreciated.
data{
int ntr; // N
int nsub;
int ParticipantID[ntr];
int nResponseTypes; // K
real x1[ntr];
real x2[ntr];
real x3[ntr];
//real x4[ntr]; //uses same input data as x3
int actionTaken[ntr];
}
parameters{
real<lower=0> invTemp[nsub];
real b_x1_pr[nsub];
real b_x2_pr[nsub];
real b_x3_pr[nsub];
}
transformed parameters {
real k[nsub];
real b_x1[nsub];
real b_x2[nsub];
real b_x3[nsub];
real b_x4[nsub];
for (is in 1:nsub){
k[is] = fabs(1) + fabs(b_x1_pr[is])+fabs(b_x2_pr[is])+fabs(b_x3_pr[is]);
b_x4[is] = 1/k[is];
b_x1[is] = b_x1_pr[is]/k[is];
b_x2[is] = b_x2_pr[is]/k[is];
b_x3[is] = b_x3_pr[is]/k[is];
}
}
model{
matrix[ntr,nResponseTypes] invTxUtil;
// Priors
invTemp ~ cauchy(10,2);
b_x1_pr ~ cauchy(0,1);
b_x2_pr ~ cauchy(0,1);
b_x3_pr ~ cauchy(0,1);
for (itr in 1:ntr) {
// Utility 1
invTxUtil[itr,1] = invTemp[ParticipantID[itr]]*(b_x1[ParticipantID[itr]]*x1[itr]);
// Utility 2
invTxUtil[itr,2] = invTemp[ParticipantID[itr]]*(b_x4[ParticipantID[itr]]*x3[itr]);
// Utility 3
invTxUtil[itr,3] = invTemp[ParticipantID[itr]]*(b_x2[ParticipantID[itr]]*x2[itr] + b_x3[ParticipantID[itr]]*x3[itr]);
}
actionTaken ~ categorical_logit(invTxUtil);
}