Model fails to initiate if I use more than a few observations - possible underflow issue?

Thanks for the response!

By following this advice I got rid of the “Rejecting initial value” problem. Note, though, that the denominator can’t be “logged” the way suggested, as the (1-crash_risk[i]) will be negative whenever the substance increases crash risk. However: the point of the denominator was just to normalize the sum of the cell-probabilities to 1 - and this is easily achieved by using logged values for the numerators and passing the softmax of the vector with numerators into the multinomial. This also means I needed to calculate the numerator of the last cell directly - to make that work with log-values I imposed a constraint that the crash_risk>1, ensuring that (crash_risk[i]-1) will be positive.

To avoid having to do Jacobian adjustments and figure out priors for probabilities on the log scale, I continue to define the prior as before and use logged values in the transformed parameters block as follows:

transformed parameters {

vector<upper=0>[study_count_culp] log_road_share;
vector<upper=0>[study_count_culp] log_culp_share;

vector[4] culp_study_shares_log[study_count_culp];
simplex[4] culp_study_shares[study_count_culp];

log_road_share = log(road_share);
log_culp_share = log(culp_share);

  // Calculate cell-probabilities for culpability crash studies.

for (i in 1:study_count_culp){
culp_study_shares_log[i,1] = log1m_exp(log_culp_share[i]) + log1m_exp(log_road_share[i]);

culp_study_shares_log[i,2] = log1m_exp(log_culp_share[i]) + log_road_share[i];

culp_study_shares_log[i,3] = log_culp_share[i] + log1m_exp(log_road_share[i]);

culp_study_shares_log[i,4] = log_sum_exp(log_culp_share[i] + log_road_share[i],
log_road_share[i]+ log(crash_risk[i]-1));

culp_study_shares[i] = softmax(culp_study_shares_log[i]);

}
}

Ole