Trouble with model convergence

47 views
Skip to first unread message

Jessica Mollick

unread,
Mar 13, 2023, 12:10:12 PM3/13/23
to hbayesdm-users
Hi hbayesdm-users,

I am sending an email to see if anyone has some insights that can help me figure out an issue with an edited version of an hbayesDM model.

To explain briefly, I made some minor edits to the ra_noLA model to allow it to capture different probabilities of reward and loss. I am noticing that the model does not seem to converge well for some specific cases in the loss condition. The rhat-values for the rho parameter are all above 1.05, and the rho parameter also looks to be bimodally distributed (i.e., often stuck at 0 or 1). I also attached the pairs plot of the mu_rho parameters along with the trace plot. 

The specific changes to the ra_noLA model were the following:
evSafe   = -pow(cert[i,t], rho[i]);
      evGamble = probs[i,t] * (pow(gain[i,t], rho[i]) - pow(loss[i,t], rho[i]) );

The negative sign in front of evSafe allows it to model loss-only gambles. 

I also changed the following in data in the stan file:
real<lower=-100,upper=100> 

fit_model_loss <- function(filename,arg1) {
  output7 <- ra_noLA_edit_losses(data = filename, niter = 2000, nwarmup = 1000, nchain = 3, ncore = 3,max_treedepth = 15)
  return(output7)
}

I would be happy to hear any ideas of insights other users of hBayesDM would have for getting this model to converge. So far I have tried: increasing the number of iterations to 4000, changing the adapt delta to 0.9 instead of the default of 0.95, and increasing the number of warmup iterations to 2000 while running it for 4000 iterations, and running it in 4 chains instead of 3. I also have some participants who always picked the safe option, but removing them did not improve the model's ability to converge. None of these strategies seemed to fix the problem in my experimentation, though I am happy to try any additional experiments or ideas anyone has. Note that the model does converge better for some other subsets of my data, but not this case.

loss_other_run2_pars.pngloss_other_run2_trace.pngpairs.png
HDI_mu_rho.png
ra_noLA_edit_losses2.stan
ra_noLA_edit_losses.R

Jessica Mollick

unread,
Mar 29, 2023, 3:21:52 PM3/29/23
to hbayesdm-users
Hi,
I thought I would send a quick follow-up email to see if anyone has any insights. I noted that the original ra_noLA in the hBayesDM folder has the following line:

transformed parameters {
  vector<lower=0, upper=2>[N] rho;
  vector<lower=0, upper=30>[N] tau;

  for (i in 1:N) {
    rho[i] = Phi_approx(mu_pr[1] + sigma[1] * rho_pr[i]) * 2;
    tau[i] = Phi_approx(mu_pr[2] + sigma[2] * tau_pr[i]) * 30;
  }
}

However, my edited version (ra_noLA_edit_losses2) has the following:
  for (i in 1:N) {
    rho[i] = Phi_approx( mu_p[1] + sigma[1] * rho_p[i] ) * 2;
  }
  tau = exp( mu_p[2] + sigma[2] * tau_p );
}

It's possible I may have made those changes prior to a change to the ra_noLA model in hBayesDM? I am now experimenting with making the edited version more similar to the original version but thought it would be useful to clarify the differences, especially if anyone remembers when those changes were made. If I understand correctly, the hBayesDM version allows a separate tau parameter for each participant, which seems more correct to me? Is there an important difference between using the Phi_approx versus exp methods for the tau parameter?

Thanks so much,
Jessica

wooyou...@gmail.com

unread,
Jun 27, 2023, 10:38:26 PM6/27/23
to hbayesdm-users
Hi Jessica, 

Sorry for the long delay! 

Let me try to answer one question at a time... so you would like to set the same tau for all individuals, right? 

Settings like this "tau = exp( mu_p[2] + sigma[2] * tau_p );" is for a hierarchical modeling. 

You should use prior settings for tau for individual-level modeling. Here is an example: https://github.com/CCS-Lab/hBayesDM/blob/develop/commons/stan_files/dd_hyperbolic_single.stan

Let us know if you have additional questions and we would be happy to address the rest!

Best,
Young
Reply all
Reply to author
Forward
0 new messages