Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/poissonconsulting/mcmcderive
Calculate derived parameters from MCMC samples
https://github.com/poissonconsulting/mcmcderive
cran derived-parameters mcmc mcmcr
Last synced: 30 days ago
JSON representation
Calculate derived parameters from MCMC samples
- Host: GitHub
- URL: https://github.com/poissonconsulting/mcmcderive
- Owner: poissonconsulting
- License: other
- Created: 2018-02-21T16:03:40.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2024-09-17T20:35:35.000Z (4 months ago)
- Last Synced: 2024-09-19T00:32:38.227Z (4 months ago)
- Topics: cran, derived-parameters, mcmc, mcmcr
- Language: R
- Homepage: https://poissonconsulting.github.io/mcmcderive/
- Size: 702 KB
- Stars: 0
- Watchers: 5
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Support: .github/SUPPORT.md
Awesome Lists containing this project
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```# mcmcderive
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
[![R-CMD-check](https://github.com/poissonconsulting/mcmcderive/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/poissonconsulting/mcmcderive/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/poissonconsulting/mcmcderive/graph/badge.svg)](https://app.codecov.io/gh/poissonconsulting/mcmcderive)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/license/mit/)
[![CRAN status](https://www.r-pkg.org/badges/version/mcmcderive)](https://cran.r-project.org/package=mcmcderive)
![CRAN downloads](http://cranlogs.r-pkg.org/badges/mcmcderive)## Why `mcmcderive`?
`mcmcderive` is an R package to generate derived parameter(s) from Monte Carlo Markov Chain (MCMC) samples using R code.
This is useful because it means Bayesian models can be fitted without the inclusion of derived parameters which add unnecessary clutter and slows model fitting.
For more information on MCMC samples see Brooks et al. (2011).## Installation
To install the latest release version from [CRAN](https://cran.r-project.org/package=mcmcderive)
```
install.packages("mcmcderive")
```To install the latest development version from [GitHub](https://github.com/poissonconsulting/mcmcderive)
```
remotes::install_github("poissonconsulting/mcmcderive")
```## Demonstration
```{r}
library(mcmcderive)mcmcr::mcmcr_example
expr <- "
log(alpha2) <- alpha
gamma <- sum(alpha) * sigma
"mcmc_derive(mcmcr::mcmcr_example, expr, silent = TRUE)
```### Parallel Chains
If the MCMC object has multiple chains the run time can be substantially reduced by generating the derived parameters for each chain in parallel.
In order for this to work it is necessary to:1) Ensure plyr and doParallel are installed using `install.packages(c("plyr", "doParallel"))`.
2) Register a parallel backend using `doParallel::registerDoParallel(4)`.
3) Set `parallel = TRUE` in the call to `mcmc_derive()`.### Extras
To facilitate the translation of model code into R code the `extras` package provides the R equivalent to common model functions such as `pow()`, `phi()` and `log() <- `.
## Contribution
Please report any [issues](https://github.com/poissonconsulting/mcmcderive/issues).
[Pull requests](https://github.com/poissonconsulting/mcmcderive/pulls) are always welcome.
## Code of Conduct
Please note that the mcmcderive project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/0/CODE_OF_CONDUCT.html).
By contributing to this project, you agree to abide by its terms.## References
Brooks, S., Gelman, A., Jones, G.L., and Meng, X.-L. (Editors). 2011. Handbook for Markov Chain Monte Carlo. Taylor & Francis, Boca Raton.