hmde
Implementation of hierarchical Bayesian longitudinal models to estimate differential equation parameters.
Science Score: 39.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 4 DOI reference(s) in README -
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.1%) to scientific vocabulary
Keywords
bayesian-inverse-problems
bayesian-methods
differential-equations
hierarchical-models
r
rstan
stan
Last synced: 6 months ago
·
JSON representation
Repository
Implementation of hierarchical Bayesian longitudinal models to estimate differential equation parameters.
Basic Info
- Host: GitHub
- Owner: traitecoevo
- Language: HTML
- Default Branch: master
- Homepage: https://traitecoevo.github.io/hmde/
- Size: 40.6 MB
Statistics
- Stars: 3
- Watchers: 2
- Forks: 4
- Open Issues: 3
- Releases: 8
Topics
bayesian-inverse-problems
bayesian-methods
differential-equations
hierarchical-models
r
rstan
stan
Created over 2 years ago
· Last pushed 7 months ago
Metadata Files
Readme
Changelog
README.Rmd
--- output: github_document --- # hmdeThe goal of hmde is to fit a model for the rate of change in some quantity based on a set of pre-defined functions arising from ecological applications. We estimate differential equation parameters from repeated observations of a process, such as growth rate parameters to data of sizes over time. In other language, `hmde` implements hierarchical Bayesian longitudinal models to solve the Bayesian inverse problem of estimating differential equation parameters based on repeat measurement surveys. Estimation is done using Markov Chain Monte Carlo, implemented through [Stan](https://mc-stan.org/) via [RStan](https://mc-stan.org/users/interfaces/rstan), built under [R](https://cran.r-project.org/) 4.3.3. The inbuilt models are based on case studies in ecology. A pre-print paper is available on [bioarXiv](https://doi.org/10.1101/2025.01.15.633280), or as the [hmde_paper.pdf](https://github.com/traitecoevo/hmde/blob/master/inst/doc/hmde_paper.pdf) file here. ## The Maths The general use case is to estimate a vector of parameters $\boldsymbol{\theta}$ for a chosen differential equation $$f\left( Y \left( t \right), \boldsymbol{\theta} \right) = \frac{dY}{dt}$$ based on the longitudinal structure $$Y \left( t_{j+1} \right) = Y\left( t_j \right) + \int_{t_j}^{t_{j+1}}f\left( Y \left( t \right), \boldsymbol{\theta} \right)\,dt. $$ The input data are observations of the form $y_{ij}$ for individual $i$ at time $t_j$, with repeated observations coming from the same individual. We parameterise $f$ at the individual level by estimating $\boldsymbol{\theta}_i$ as the vector of parameters. We have hyper-parameters that determine the distribution of $\boldsymbol{\theta}_i$ with typical prior distribution $$\boldsymbol{\theta}_i \sim \log \mathcal{N}\left(\boldsymbol{\mu}_{\log\left(\boldsymbol{\theta}\right)}, \boldsymbol{\sigma}_{\log \left( \boldsymbol{\theta} \right)}\right), $$ where $\boldsymbol{\mu}_{\log\left(\boldsymbol{\theta}\right)}$ and $\boldsymbol{\sigma}_{\log\left(\boldsymbol{\theta}\right)}$ are vectors of means and standard deviations. In the case of a single individual, these are chosen prior values. In the case of a multi-individual model $\boldsymbol{\mu}_{\log\left(\boldsymbol{\theta}\right)}$ and $\boldsymbol{\sigma}_{\log\left(\boldsymbol{\theta}\right)}$ have their own prior distributions and are fit to data. ## Implemented Models `hmde` comes with four DEs built and ready to go, each of which has a version for a single individual and multiple individuals. ### Constant Model The constant model is given by $$f \left( Y \left( t \right), \beta \right) = \frac{dY}{dt} = \beta,$$ and is best understood as describing the average rate of change over time. ### von Bertalanffy The von Bertalanffy mode is given by $$f \left( Y \left( t \right), \beta, Y_{max} \right) = \frac{dY}{dt} = \beta \left( Y_{max} - Y \left( t \right) \right),$$ where $\beta$ is the growth rate parameter and $Y_{max}$ is the maximum value that $Y$ takes. ### Canham The Canham ([Canham et al. 2004](https://doi.org/10.1890/1051-0761(2006)016%5B0540:NAOCTC%5D2.0.CO;2)) model is a hump-shaped function given by $$f \left( Y \left( t \right), f_{max}, Y_{max}, k \right) = \frac{dY}{dt} = f_{max} \exp \Bigg( -\frac{1}{2} \bigg( \frac{ \ln \left( Y \left( t \right) / Y_{max} \right) }{k} \bigg)^2 \Bigg), $$ where $f_{max}$ is the maximum growth rate, $Y_{max}$ is the $Y$-value at which that maximum occurs, and $k$ controls how narrow or wide the peak is. ## Installation ‘hmde’ is under active development. You can install the current developmental version of ‘hmde’ from [GitHub](https://github.com/) with: ``` r # install.packages("remotes") remotes::install_github("traitecoevo/hmde") ``` ## Quick demo Create constant growth data with measurement error: ``` r library(hmde) y_obs <- seq(from=2, to=15, length.out=10) + rnorm(10, 0, 0.1) ``` Measurement error is necessary as otherwise the normal likelihood $$s_{ij} \sim \mathcal{N}\left( 0, \sigma_e \right)$$ blows up as $\sigma_e$ approaches 0. Fit the model: ``` r constant_fit <- hmde_model("constant_single_ind") |> hmde_assign_data(n_obs = 10, #Integer y_obs = y_obs, #vector length n_obs obs_index = 1:10, #vector length n_obs time = 0:9, #Vector length n_obs y_0_obs = y_obs[1] #Real ) |> hmde_run(chains = 1, iter = 1000, verbose = FALSE, show_messages = FALSE) ``` ## Found a bug? Please submit a [GitHub issue](https://github.com/traitecoevo/hmde/issues) with details of the bug. A [reprex](https://reprex.tidyverse.org/) would be particularly helpful with the bug-proofing process!
Owner
- Name: Trait Ecology and Evolution
- Login: traitecoevo
- Kind: organization
- Location: Australia
- Repositories: 64
- Profile: https://github.com/traitecoevo
GitHub Events
Total
- Create event: 32
- Release event: 5
- Issues event: 17
- Watch event: 1
- Delete event: 32
- Issue comment event: 24
- Push event: 188
- Pull request review event: 38
- Pull request review comment event: 27
- Pull request event: 53
Last Year
- Create event: 32
- Release event: 5
- Issues event: 17
- Watch event: 1
- Delete event: 32
- Issue comment event: 24
- Push event: 188
- Pull request review event: 38
- Pull request review comment event: 27
- Pull request event: 53
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 9
- Total pull requests: 16
- Average time to close issues: 3 months
- Average time to close pull requests: 6 days
- Total issue authors: 4
- Total pull request authors: 2
- Average comments per issue: 0.44
- Average comments per pull request: 0.38
- Merged pull requests: 14
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 8
- Pull requests: 16
- Average time to close issues: 24 days
- Average time to close pull requests: 6 days
- Issue authors: 3
- Pull request authors: 2
- Average comments per issue: 0.25
- Average comments per pull request: 0.38
- Merged pull requests: 14
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- Tess-LaCoil (13)
- dfalster (2)
- teunbrand (1)
- fontikar (1)
- ehwenk (1)
Pull Request Authors
- Tess-LaCoil (29)
- fontikar (1)
- dfalster (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- cran 192 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 1
- Total maintainers: 1
cran.r-project.org: hmde
Hierarchical Methods for Differential Equations
- Homepage: https://traitecoevo.github.io/hmde/
- Documentation: http://cran.r-project.org/web/packages/hmde/hmde.pdf
- License: GPL (≥ 3)
-
Latest release: 1.2.1
published 8 months ago
Rankings
Dependent packages count: 26.1%
Dependent repos count: 32.1%
Average: 48.2%
Downloads: 86.3%
Maintainers (1)
Last synced:
6 months ago
Dependencies
.github/workflows/R-CMD-check.yaml
actions
- actions/checkout v3 composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/test-coverage.yaml
actions
- actions/checkout v3 composite
- actions/upload-artifact v3 composite
- codecov/codecov-action v3 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
DESCRIPTION
cran
- R >= 3.4.0 depends
- Rcpp >= 0.12.0 imports
- RcppParallel >= 5.0.1 imports
- methods * imports
- purrr * imports
- rlang * imports
- rstan >= 2.18.1 imports
- rstantools >= 2.3.1.1 imports
- stats * imports
- knitr * suggests
- rmarkdown * suggests
- testthat >= 3.0.0 suggests
The goal of hmde is to fit a model for the rate of change in some quantity based on a set of pre-defined functions arising from ecological applications. We estimate differential equation parameters from repeated observations of a process, such as growth rate parameters to data of sizes over time.
In other language, `hmde` implements hierarchical Bayesian longitudinal models to solve the Bayesian inverse problem of estimating differential equation parameters based on repeat measurement surveys. Estimation is done using Markov Chain Monte Carlo, implemented through
[Stan](https://mc-stan.org/) via [RStan](https://mc-stan.org/users/interfaces/rstan), built under [R](https://cran.r-project.org/) 4.3.3. The inbuilt models are based on case studies in ecology.
A pre-print paper is available on [bioarXiv](https://doi.org/10.1101/2025.01.15.633280), or as the [hmde_paper.pdf](https://github.com/traitecoevo/hmde/blob/master/inst/doc/hmde_paper.pdf) file here.
## The Maths
The general use case is to estimate a vector of parameters