Skip to content

Dev dirchlet linear - #1516

Open
msupernaw wants to merge 33 commits into
mainfrom
dev-dirchlet-linear
Open

Dev dirchlet linear#1516
msupernaw wants to merge 33 commits into
mainfrom
dev-dirchlet-linear

Conversation

@msupernaw

@msupernaw msupernaw commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

What is the feature?

  • Makes the Dirichlet linear multinomial available for the power user. Wrapper functions currently can't accommodate anything other than multinomial.

How have you implemented the solution?

  • Implemented the Dirichlet linear multinomial in the backend code.

Does the PR impact any other area of the project, maybe another repo?

  • no

Instructions for code reviewer

👋Hello reviewer👋, thank you for taking the time to review this PR!

  • Please use this checklist during your review, checking off items that you have verified are complete but feel free to skip over items that are not relevant!
  • See the GitHub documentation for how to comment on a PR to indicate where you have questions or changes are needed before approving the PR.
  • Please use standard conventional messages for both commit messages and comments
  • PR reviews are a great way to learn so feel free to share your tips and tricks. However, when suggesting changes to the PR that are optional please include nit: (for nitpicking) as the comment type. For example, nit: I prefer using a data.frame() instead of a matrix because ...
  • Engage with the developer. Make it clear when the PR is approved by selecting the approved status, and potentially commenting on the PR with something like This PR is now ready to be merged.

Checklist

  • The code is well-designed
  • The code is designed well for both users and developers
  • Code coverage remains high- [ ] Comments are clear, useful, and explain why instead of what
  • Code is appropriately documented (doxygen and roxygen)

@kellijohnson-NOAA

Copy link
Copy Markdown
Contributor

This branch needs to be rebased to main. I have done it locally and can push for you if you want but I wasn't sure what was best for you given there are two of you working on this branch. With the rebase, I wiped out all changes to tests/gtest/CmakeLists.txt and then added the Dirchlet-mulitnomial test back in after near the fimsMath tests rather than at the end of the file. Second, why do you have the naming convention of ddiric_multinom rather than spelling it out in full? There are quite a few abbreviations like this that I think should be written out in full for comprehension purposes. Additionally, if the words are written out in full then the changes to the WORDLIST file will be slim to none. There was some code added to the R directory but it is not complete and should probably be removed.
Once these things are fixed, I will assign Andrea to review it.

JonBrodziak and others added 24 commits August 24, 2026 12:11
Removed comment about using the FIMS custom sum function.
Removed unnecessary include for fims_vector.hpp.
…test inputs for DM PMF read from csv created and verified with "Test_value_diric_multinom.R"
Use the global lgamma (::lgamma) in ddiric_multinom to avoid incorrect fims_math resolution, and update calls accordingly. Add fims_math include to the Dirichlet-multinomial functor and export the functor header from distributions.hpp. Fix Rcpp distribution interface bugs and naming/initialization issues: correct make_shared/copy-constructor types for the DDirichletMultinomial interface, initialize the underlying theta from initial_value_m, and update Rcpp bindings (method names, fields and expose theta). These changes address compilation/runtime errors and ensure the Dirichlet-multinomial distribution is properly registered and usable from R.
Export DDirichletMultinomDistribution in NAMESPACE to make the new distribution available to package users. Also add DDirichletMultinomialDistributionsInterface to inst/WORDLIST so the identifier is recognized by the package wordlist (avoids spellcheck/lint issues).
Added 'dirichlet_multinomial' to available distributions and created a new function for it.
Updated documentation @details to clarify the implementation of the Dirichlet-multinomial log-probability mass function.
…roposed fix to switch between composition distribution types in "fix_helper_setup_R1.docx". More general solution recommended for multiple composition types and other submodel components.
…ration-tests-validation.R to support Dirichlet-Multinomial distribution.
@msupernaw
msupernaw force-pushed the dev-dirchlet-linear branch from 77a1e1b to 9a653d8 Compare August 24, 2026 16:20
@codecov

codecov Bot commented Aug 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 30.23256% with 210 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.32%. Comparing base (f04ecb7) to head (4b8c31d).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
.../interface/rcpp/rcpp_objects/rcpp_distribution.hpp 0.00% 139 Missing ⚠️
...tributions/functors/dirichlet_multinomial_lpmf.hpp 0.00% 51 Missing ⚠️
tests/gtest/test_fims_math_ddirichlet_multinom.cpp 82.71% 8 Missing and 6 partials ⚠️
R/distribution_formulas.R 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1516      +/-   ##
==========================================
- Coverage   85.02%   83.32%   -1.70%     
==========================================
  Files         106      108       +2     
  Lines        9386     9692     +306     
  Branches      537      555      +18     
==========================================
+ Hits         7980     8076      +96     
- Misses       1369     1573     +204     
- Partials       37       43       +6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Type theta_n = theta * n;

// 1. Base Multinomial combinatorial term: log(n!) = lgamma(n + 1)
Type log_like = ::lgamma(n + static_cast<Type>(1.0));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use fims_math::lgamma, which uses TMB's atomic lgamma function when #ifdef TMB_MODEL and std::lgamma when TMB is not defined. We could also use lgamma without the global :: in front, but we might prefer to be more explicit.

@kellijohnson-NOAA

Copy link
Copy Markdown
Contributor

@msupernaw the branch is failing the pkgdown action because of missing documentation. In inst/include/interface/rcpp/rcpp_objects/rcpp_distribution.hpp, add a class-level doc block for DDirichletMultinomialDistributionsInterface and a member doc for theta.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Dirichlet-multinomial likelihood for composition data

4 participants