timjmiller / wham

State-space, age-structured fish stock assessment model
https://timjmiller.github.io/wham
Other
32 stars 16 forks source link

Expanding the Dirichlet Multinomial Library #58

Closed emilylil closed 2 years ago

emilylil commented 2 years ago

Hi All, I'd like to add a few more options for using the Dirichlet-Multinomial to fit composition data. Basically, since this distribution does not allow for 0 observations, I want to make some options akin to "miss0" and "pool" which ignore or pool the 0s, respectively, and already exist for the Dirichlet and Logistic Normal distributions. This would be my first time forking and contributing to a project, but I think I've identified the right code in age_comp_osa.hpp. I could add: age_comp_model =10 for dirichlet-multinomial, miss0 age_comp_model =11 for dirichlet-multinomial, pool0

timjmiller commented 2 years ago

Hey there, report back if you are getting errors with 0s using the Dirichlet-multinomial option. This distribution (like the multinomial) should allow 0s.

emilylil commented 2 years ago

Hi Tim, The model runs fine when I specify a dirichlet for the age compositions of catch, but when I specify the dir-mult, it messes up during the fitting process. I thought the issue might be 0s, but you're right, maybe its something else, especially if the distribution should allow 0s.

timjmiller commented 2 years ago

Convergence with the D-M can be an issue because of the bounds on the estimated over-dispersion term and dependence on the assumed effective sample size. I have been able to obtain convergence by increasing the assumed ESS, but I can't say whether that is a good practice.

emilylil commented 2 years ago

Sorry, I see now that ddirmultinom() function does account for 0s by adding 1.0 to observed values before applying the lgamma. If I have time in the next few months, and with your permission, I'd like to try adding a few other alternative likelihoods- perhaps conditional log gaussian cox process or tweedie. Both are under study by Noel Cadigan and Jim Thorson, respectively. Perhaps fitting catch at age using multivariate log normal, like SAM.

emilylil commented 2 years ago

I've gone back to using the multinomial and no longer plan to use alternative likelihood structures for my age compositions.