Calculating log_like for WAIC/LOO with user defined functions

Hi Max,

Thanks a ton for your quick reply and assistance. I think I understand what’s happening here—in the original model, it’s assessing the likelihood of each capture using 1 ~ bernoulli statements, whereas in your adjustment it is explicitly calculating the bernoulli_lmpf for each individual and aggregating that into log_lik individual by individual (correct me if I’m wrong?). That allows for the explicit calculation of a log likelihood, instead of it just running in the background and not being recorded.

Hiroki Ito made very similar changes when he was helping me add in a sex effect with a mix of observed and unknown sexes. Adding the sex effect roughly doubled the population abundance, and now I’m curious to see if that was truly just the addition of sex or if that had something to do with the way the likelihood was calculated for each individual. Hopefully it’s the former, and this will be a good test.

I modified your code to fit my specific case and it’s running well. I should know in a couple of days if the results are the same as the previous model, so I’ll report back then.

Many thanks again for your help!

Cheers,
Josh