{"id":27646770,"url":"https://github.com/maxbiostat/comp_stan","last_synced_at":"2025-04-24T01:23:38.116Z","repository":{"id":52899864,"uuid":"347747429","full_name":"maxbiostat/COMP_Stan","owner":"maxbiostat","description":"Implementing the Conway-Maxwell Poisson distribution in Stan.","archived":false,"fork":false,"pushed_at":"2022-05-21T18:27:57.000Z","size":1523,"stargazers_count":1,"open_issues_count":6,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2023-07-31T12:36:11.961Z","etag":null,"topics":["stan","statistics","truncation"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maxbiostat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-14T20:32:56.000Z","updated_at":"2023-07-31T12:36:11.962Z","dependencies_parsed_at":"2022-08-23T20:40:54.288Z","dependency_job_id":null,"html_url":"https://github.com/maxbiostat/COMP_Stan","commit_stats":null,"previous_names":[],"tags_count":1,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxbiostat%2FCOMP_Stan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxbiostat%2FCOMP_Stan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxbiostat%2FCOMP_Stan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxbiostat%2FCOMP_Stan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxbiostat","download_url":"https://codeload.github.com/maxbiostat/COMP_Stan/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250541962,"owners_count":21447608,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["stan","statistics","truncation"],"created_at":"2025-04-24T01:23:37.592Z","updated_at":"2025-04-24T01:23:38.108Z","avatar_url":"https://github.com/maxbiostat.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"# COMP Stan\nImplementing the Conway-Maxwell Poisson distribution in Stan. Code uses [stan_summer](https://github.com/GuidoAMoreira/stan_summer) as a submodule. \n\n## Goal\nApproximately compute the normalising constant of a [Conway-Maxwell Poisson](https://en.wikipedia.org/wiki/Conway%E2%80%93Maxwell%E2%80%93Poisson_distribution) distribution with parameters `mu` and `nu`. \n\n## Methods and implementations being compared\n\n- **Asymptotic**: use the asymptotic expansion of [Gaunt et al. 2019](https://ideas.repec.org/a/spr/aistmt/v71y2019i1d10.1007_s10463-017-0629-6.html) with four terms.\n- **SumToThreshold**: For a given `eps`, sum until `lterm \u003c log(eps)`;\n- **ErrorBoundingPair**: for a given `eps`, this method guarantees an answer within `eps`. Uses elementary results from convergent series.\n- **bmrs**: similar to the [current implementation]( https://github.com/paul-buerkner/brms/blob/master/inst/chunks/fun_com_poisson.stan) in brms with bug fixes and a bit of streamlining.\n- **brms_bulk** similar to the above, but summing everything at once, 'in bulk'.\n\nSee [Carvalho \u0026 Moreira (2022)](https://arxiv.org/abs/2202.06121) for more details.\n\n\n## Criteria for comparison\n\nWe will be looking at \n- Error (in the original scale) to the true value (computed either exactly or with a stupidly large number of terms);\n- Whether the absolute error is within a given `eps`;\n- Number of function evaluations needed to achieve the approximation (not applicable for the asymptotic approximation).\nWhen doing MCMC we will be looking at\n- ESS/time for `mu`,  `nu` and `lp__`;\n- `max_treedepth` exceedances;\n- Divergences.\n\n## Step 0: correctness\n\nThe first bar to clear is that of correctly returning the answer within the error bound requested.\nOf course, not every method comes with mathematical guarantees (e.g. the asymptotic expansion of Gaunt et al. makes no promises about using finitely many terms).\nIt is nevertheless useful to record whether each method/implementation got the answer within a certain tolerance in order to gauge their overall accuracy under many scenarios.\nThis can be found in [testing_implementations_grid.r](https://github.com/maxbiostat/COMP_Stan/blob/main/testing_implementations_grid.r).\n\n## Step 1: MCMC\n\nThe next step is to see what happens when these implementations are actually used in MCMC.\nThis is implemented in [fit_simple_COMP.r](https://github.com/maxbiostat/COMP_Stan/blob/main/fit_simple_COMP.r).\nWe provide a real world analysis of inventory data [here](https://github.com/maxbiostat/COMP_Stan/blob/main/fit_inventory_COMP_reparametrisation.r). \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxbiostat%2Fcomp_stan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxbiostat%2Fcomp_stan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxbiostat%2Fcomp_stan/lists"}