The stantargets R package
The stantargets R package: a workflow framework for efficient reproducible Stan-powered Bayesian data analysis pipelines - Published in JOSS (2021)
Science Score: 93.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 and JOSS metadata -
✓Academic publication links
Links to: joss.theoj.org, zenodo.org -
○Committers with academic emails
-
○Institutional organization owner
-
✓JOSS paper metadata
Published in Journal of Open Source Software
Keywords
bayesian
high-performance-computing
make
r
r-targetopia
reproducibility
rstats
rstats-package
stan
statistics
targets
Keywords from Contributors
drake
makefile
ropensci
Last synced: 4 months ago
·
JSON representation
Repository
Reproducible Bayesian data analysis pipelines with targets and cmdstanr
Basic Info
- Host: GitHub
- Owner: ropensci
- License: other
- Language: R
- Default Branch: main
- Homepage: https://docs.ropensci.org/stantargets
- Size: 1.43 MB
Statistics
- Stars: 50
- Watchers: 7
- Forks: 10
- Open Issues: 3
- Releases: 8
Topics
bayesian
high-performance-computing
make
r
r-targetopia
reproducibility
rstats
rstats-package
stan
statistics
targets
Created about 5 years ago
· Last pushed 4 months ago
Metadata Files
Readme
Changelog
Contributing
License
Codemeta
README.Rmd
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# stantargets
[](https://github.com/ropensci/software-review/issues/430)
[](https://doi.org/10.21105/joss.03193)
[](https://zenodo.org/badge/latestdoi/315447649)
[](https://wlandau.github.io/targetopia/)
[](https://www.repostatus.org/#active)
[](https://github.com/ropensci/stantargets/actions?query=workflow%3Acheck)
[](https://app.codecov.io/gh/ropensci/stantargets)
[](https://github.com/ropensci/stantargets/actions?query=workflow%3Alint)
Bayesian data analysis usually incurs long runtimes and cumbersome custom code, and the process of prototyping and deploying custom [Stan](https://mc-stan.org) models can become a daunting software engineering challenge. To ease this burden, the `stantargets` R package creates [Stan](https://mc-stan.org) pipelines that are concise, efficient, scalable, and tailored to the needs of Bayesian statisticians. Leveraging [`targets`](https://docs.ropensci.org/targets/), `stantargets` pipelines automatically parallelize the computation and skip expensive steps when the results are already up to date. Minimal custom user-side code is required, and there is no need to manually configure branching, so `stantargets` is easier to use than [`targets`](https://docs.ropensci.org/targets/) and [`CmdStanR`](https://mc-stan.org/cmdstanr/) directly. `stantargets` can access all of [`cmdstanr`](https://github.com/stan-dev/cmdstanr)'s major algorithms (MCMC, variational Bayes, and optimization) and it supports both single-fit workflows and multi-rep simulation studies.
## Prerequisites
1. The [prerequisites of the `targets` R package](https://docs.ropensci.org/targets/index.html#prerequisites).
1. Basic familiarity with [`targets`](https://docs.ropensci.org/targets/): watch minutes 7 through 40 of [this video](https://youtu.be/Gqn7Xn4d5NI?t=439), then read [this chapter](https://books.ropensci.org/targets/walkthrough.html) of the [user manual](https://books.ropensci.org/targets/).
1. Familiarity with Bayesian Statistics and [Stan](https://mc-stan.org/). Prior knowledge of [`cmdstanr`](https://mc-stan.org/cmdstanr/) helps.
## How to get started
Read the `stantargets` [introduction](https://docs.ropensci.org/stantargets/articles/introduction.html) and [simulation](https://docs.ropensci.org/stantargets/articles/simulation.html) vignettes, and use as a reference while constructing your own workflows. Visit for an example project based on the [simulation vignette](https://docs.ropensci.org/stantargets/articles/simulation.html). The example has an [RStudio Cloud workspace](https://rstudio.cloud/project/2466069) which allows you to run the project in a web browser.
## Example projects
Description | Link
---|---
Validating a minimal Stan model |
Using Target Markdown and `stantargets` to validate a Bayesian longitudinal model for clinical trial data analysis |
## Installation
Install the GitHub development version to access the latest features and patches.
```{r, eval = FALSE}
remotes::install_github("ropensci/stantargets")
```
The [CmdStan](https://github.com/stan-dev/cmdstan) command line interface is also required.
```{r, eval = FALSE}
cmdstanr::install_cmdstan()
```
If you have problems installing [CmdStan](https://github.com/stan-dev/cmdstan), please consult the [installation guide of `cmdstanr`](https://mc-stan.org/cmdstanr/articles/cmdstanr.html) and the [installation guide of CmdStan](https://mc-stan.org/docs/2_26/cmdstan-guide/cmdstan-installation.html). Alternatively, the [Stan discourse](https://discourse.mc-stan.org) is a friendly place to ask Stan experts for help.
## Usage
First, write a [`_targets.R` file](https://books.ropensci.org/targets/walkthrough.html) that loads your packages, defines a function to generate [Stan](https://mc-stan.org/) data, and lists a pipeline of targets. The target list can call target factories like [`tar_stan_mcmc()`](https://docs.ropensci.org/stantargets/reference/tar_stan_mcmc.html) as well as ordinary targets with [`tar_target()`](https://docs.ropensci.org/targets/reference/tar_target.html). The following minimal example is simple enough to contain entirely within the `_targets.R` file, but for larger projects, you may wish to store functions in separate files as in the [`targets-stan`](https://github.com/wlandau/targets-stan) example.
```{r, eval = FALSE}
# _targets.R
library(targets)
library(stantargets)
generate_data <- function() {
true_beta <- stats::rnorm(n = 1, mean = 0, sd = 1)
x <- seq(from = -1, to = 1, length.out = n)
y <- stats::rnorm(n, x * true_beta, 1)
list(n = n, x = x, y = y, true_beta = true_beta)
}
list(
tar_stan_mcmc(
name = example,
stan_files = "x.stan",
data = generate_data()
)
)
```
Run [`tar_visnetwork()`](https://docs.ropensci.org/targets/reference/tar_visnetwork.html) to check `_targets.R` for correctness, then call [`tar_make()`](https://docs.ropensci.org/targets/reference/tar_make.html) to run the pipeline. Access the results using [`tar_read()`](https://docs.ropensci.org/targets/reference/tar_read.html), e.g. `tar_read(example_summary_x)`. Visit the [introductory vignette](https://docs.ropensci.org/stantargets/articles/introduction.html) to read more about this example.
## How it works behind the scenes
`stantargets` supports specialized [target factories](https://ropensci.org/blog/2021/02/03/targets/#target-factories) that create ensembles of [target objects](https://docs.ropensci.org/targets/reference/tar_target.html) for [`cmdstanr`](https://github.com/stan-dev/cmdstanr) workflows. These [target factories](https://ropensci.org/blog/2021/02/03/targets/#target-factories) abstract away the details of [`targets`](https://docs.ropensci.org/targets/) and [`cmdstanr`](https://github.com/stan-dev/cmdstanr) and make both packages easier to use. For details, please read the [introductory vignette](https://docs.ropensci.org/stantargets/articles/introduction.html).
## Help
Please first read the [help guide](https://books.ropensci.org/targets/help.html) to learn how best to ask for help.
If you have trouble using `stantargets`, you can ask for help in the [GitHub discussions forum](https://github.com/ropensci/stantargets/discussions/categories/help). Because the purpose of `stantargets` is to combine [`targets`](https://docs.ropensci.org/targets/) and [`cmdstanr`](https://github.com/stan-dev/cmdstanr), your issue may have something to do with one of the latter two packages, a [dependency of `targets`](https://github.com/ropensci/targets/blob/4e3ef2a6c986f558a25e544416f480fc01236b6b/DESCRIPTION#L49-L88), or [Stan](https://mc-stan.org) itself. When you troubleshoot, peel back as many layers as possible to isolate the problem. For example, if the issue comes from [`cmdstanr`](https://github.com/stan-dev/cmdstanr), create a [reproducible example](https://reprex.tidyverse.org) that directly invokes [`cmdstanr`](https://github.com/stan-dev/cmdstanr) without invoking `stantargets`. The GitHub discussion and issue forums of those packages, as well as the [Stan discourse](https://discourse.mc-stan.org), are great resources.
## Participation
Development is a community effort, and we welcome discussion and contribution. Please note that this package is released with a [Contributor Code of Conduct](https://ropensci.org/code-of-conduct/). By contributing to this project, you agree to abide by its terms.
## Citation
```{r, warning = FALSE}
citation("stantargets")
```
Owner
- Name: rOpenSci
- Login: ropensci
- Kind: organization
- Email: info@ropensci.org
- Location: Berkeley, CA
- Website: https://ropensci.org/
- Twitter: rOpenSci
- Repositories: 307
- Profile: https://github.com/ropensci
JOSS Publication
The stantargets R package: a workflow framework for efficient reproducible Stan-powered Bayesian data analysis pipelines
Published
April 21, 2021
Volume 6, Issue 60, Page 3193
Tags
reproducibility high-performance computing pipeline workflow Make BayesianCodeMeta (codemeta.json)
{
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
"@type": "SoftwareSourceCode",
"identifier": "stantargets",
"description": "Bayesian data analysis usually incurs long runtimes and cumbersome custom code. A pipeline toolkit tailored to Bayesian statisticians, the 'stantargets' R package leverages 'targets' and 'cmdstanr' to ease these burdens. 'stantargets' makes it super easy to set up scalable Stan pipelines that automatically parallelize the computation and skip expensive steps when the results are already up to date. Minimal custom code is required, and there is no need to manually configure branching, so usage is much easier than 'targets' alone. 'stantargets' can access all of 'cmdstanr''s major algorithms (MCMC, variational Bayes, and optimization) and it supports both single-fit workflows and multi-rep simulation studies. For the statistical methodology, please refer to 'Stan' documentation (Stan Development Team 2020) <https://mc-stan.org/>.",
"name": "stantargets: Targets for Stan Workflows",
"relatedLink": "https://docs.ropensci.org/stantargets/",
"codeRepository": "https://github.com/ropensci/stantargets",
"issueTracker": "https://github.com/ropensci/stantargets/issues",
"license": "https://spdx.org/licenses/MIT",
"version": "0.1.1",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
"url": "https://r-project.org"
},
"runtimePlatform": "R version 4.3.2 (2023-10-31)",
"author": [
{
"@type": "Person",
"givenName": [
"William",
"Michael"
],
"familyName": "Landau",
"email": "will.landau.oss@gmail.com",
"@id": "https://orcid.org/0000-0003-1878-3253"
}
],
"copyrightHolder": [
{
"@type": "Organization",
"name": "Eli Lilly and Company"
}
],
"maintainer": [
{
"@type": "Person",
"givenName": [
"William",
"Michael"
],
"familyName": "Landau",
"email": "will.landau.oss@gmail.com",
"@id": "https://orcid.org/0000-0003-1878-3253"
}
],
"softwareSuggestions": [
{
"@type": "SoftwareApplication",
"identifier": "dplyr",
"name": "dplyr",
"version": ">= 1.0.2",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=dplyr"
},
{
"@type": "SoftwareApplication",
"identifier": "ggplot2",
"name": "ggplot2",
"version": ">= 3.0.0",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=ggplot2"
},
{
"@type": "SoftwareApplication",
"identifier": "knitr",
"name": "knitr",
"version": ">= 1.30",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=knitr"
},
{
"@type": "SoftwareApplication",
"identifier": "R.utils",
"name": "R.utils",
"version": ">= 2.10.1",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=R.utils"
},
{
"@type": "SoftwareApplication",
"identifier": "rmarkdown",
"name": "rmarkdown",
"version": ">= 2.3",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=rmarkdown"
},
{
"@type": "SoftwareApplication",
"identifier": "SBC",
"name": "SBC",
"version": ">= 0.2.0",
"sameAs": "https://github.com/hyunjimoon/SBC"
},
{
"@type": "SoftwareApplication",
"identifier": "testthat",
"name": "testthat",
"version": ">= 3.0.0",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=testthat"
},
{
"@type": "SoftwareApplication",
"identifier": "tidyr",
"name": "tidyr",
"version": ">= 1.0.0",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=tidyr"
},
{
"@type": "SoftwareApplication",
"identifier": "visNetwork",
"name": "visNetwork",
"version": ">= 2.0.9",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=visNetwork"
}
],
"softwareRequirements": {
"1": {
"@type": "SoftwareApplication",
"identifier": "R",
"name": "R",
"version": ">= 3.5.0"
},
"2": {
"@type": "SoftwareApplication",
"identifier": "cmdstanr",
"name": "cmdstanr",
"version": ">= 0.5.0",
"sameAs": "https://github.com/stan-dev/cmdstanr"
},
"3": {
"@type": "SoftwareApplication",
"identifier": "fs",
"name": "fs",
"version": ">= 1.5.0",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=fs"
},
"4": {
"@type": "SoftwareApplication",
"identifier": "fst",
"name": "fst",
"version": ">= 0.9.2",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=fst"
},
"5": {
"@type": "SoftwareApplication",
"identifier": "posterior",
"name": "posterior",
"version": ">= 1.0.1",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=posterior"
},
"6": {
"@type": "SoftwareApplication",
"identifier": "purrr",
"name": "purrr",
"version": ">= 0.3.4",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=purrr"
},
"7": {
"@type": "SoftwareApplication",
"identifier": "qs",
"name": "qs",
"version": ">= 0.23.2",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=qs"
},
"8": {
"@type": "SoftwareApplication",
"identifier": "rlang",
"name": "rlang",
"version": ">= 0.4.10",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=rlang"
},
"9": {
"@type": "SoftwareApplication",
"identifier": "secretbase",
"name": "secretbase",
"version": ">= 0.4.0",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=secretbase"
},
"10": {
"@type": "SoftwareApplication",
"identifier": "stats",
"name": "stats"
},
"11": {
"@type": "SoftwareApplication",
"identifier": "targets",
"name": "targets",
"version": ">= 1.5.1.9001",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=targets"
},
"12": {
"@type": "SoftwareApplication",
"identifier": "tarchetypes",
"name": "tarchetypes",
"version": ">= 0.7.12.9001",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=tarchetypes"
},
"13": {
"@type": "SoftwareApplication",
"identifier": "tibble",
"name": "tibble",
"version": ">= 3.0.1",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=tibble"
},
"14": {
"@type": "SoftwareApplication",
"identifier": "tidyselect",
"name": "tidyselect",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=tidyselect"
},
"15": {
"@type": "SoftwareApplication",
"identifier": "withr",
"name": "withr",
"version": ">= 2.1.2",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=withr"
},
"SystemRequirements": "CmdStan >= 2.25.0"
},
"fileSize": "982.447KB",
"citation": [
{
"@type": "ScholarlyArticle",
"datePublished": "2021",
"author": [
{
"@type": "Person",
"givenName": [
"William",
"Michael"
],
"familyName": "Landau"
}
],
"name": "The stantargets {R} package: a workflow framework for efficient reproducible {S}tan-powered {B}ayesian data analysis pipelines",
"url": "https://doi.org/10.21105/joss.03193",
"pagination": "3193",
"isPartOf": {
"@type": "PublicationIssue",
"issueNumber": "60",
"datePublished": "2021",
"isPartOf": {
"@type": [
"PublicationVolume",
"Periodical"
],
"volumeNumber": "6",
"name": "Journal of Open Source Software"
}
}
}
],
"releaseNotes": "https://github.com/ropensci/stantargets/blob/master/NEWS.md",
"readme": "https://github.com/ropensci/stantargets/blob/main/README.md",
"contIntegration": [
"https://github.com/ropensci/stantargets/actions?query=workflow%3Acheck",
"https://app.codecov.io/gh/ropensci/stantargets",
"https://github.com/ropensci/stantargets/actions?query=workflow%3Alint"
],
"developmentStatus": "https://www.repostatus.org/#active",
"review": {
"@type": "Review",
"url": "https://github.com/ropensci/software-review/issues/430",
"provider": "https://ropensci.org"
},
"keywords": [
"r",
"rstats",
"reproducibility",
"high-performance-computing",
"stan",
"bayesian",
"statistics",
"targets",
"make",
"rstats-package",
"r-targetopia"
]
}
GitHub Events
Total
- Create event: 1
- Release event: 1
- Issues event: 3
- Watch event: 4
- Issue comment event: 4
- Push event: 9
- Fork event: 2
Last Year
- Create event: 1
- Release event: 1
- Issues event: 3
- Watch event: 4
- Issue comment event: 4
- Push event: 9
- Fork event: 2
Committers
Last synced: 5 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| wlandau | w****u@g****m | 336 |
| Will Landau | 1****u | 7 |
| Maëlle Salmon | m****n@y****e | 3 |
Issues and Pull Requests
Last synced: 4 months ago
All Time
- Total issues: 32
- Total pull requests: 7
- Average time to close issues: 20 days
- Average time to close pull requests: 19 days
- Total issue authors: 6
- Total pull request authors: 4
- Average comments per issue: 1.5
- Average comments per pull request: 0.71
- Merged pull requests: 5
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 2
- Pull requests: 0
- Average time to close issues: 2 days
- Average time to close pull requests: N/A
- Issue authors: 2
- Pull request authors: 0
- Average comments per issue: 2.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- wlandau (24)
- maelle (3)
- stuvet (2)
- adammwilson (1)
- ihuff (1)
- odaniel1 (1)
Pull Request Authors
- wlandau (3)
- maelle (2)
- stuvet (2)
- wlandau-lilly (1)
Top Labels
Issue Labels
type: new feature (11)
order: later (4)
type: potential direction (4)
type: bug (2)
type: maintenance (1)
topic: style (1)
topic: documentation (1)
type: trouble (1)
Pull Request Labels
type: new feature (1)
Dependencies
DESCRIPTION
cran
- R >= 3.5.0 depends
- cmdstanr >= 0.5.0 imports
- digest >= 0.6.25 imports
- fs >= 1.5.0 imports
- fst >= 0.9.2 imports
- posterior >= 1.0.1 imports
- purrr >= 0.3.4 imports
- qs >= 0.23.2 imports
- rlang >= 0.4.10 imports
- stats * imports
- tarchetypes >= 0.6.0 imports
- targets >= 0.12.0 imports
- tibble >= 3.0.1 imports
- withr >= 2.1.2 imports
- R.utils >= 2.10.1 suggests
- dplyr >= 1.0.2 suggests
- knitr >= 1.30 suggests
- rmarkdown >= 2.3 suggests
- testthat >= 3.0.0 suggests
- visNetwork >= 2.0.9 suggests
.github/workflows/check.yaml
actions
- actions/checkout v3 composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-pandoc v2.2.4 composite
- r-lib/actions/setup-r v2.2.4 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/cover.yaml
actions
- actions/checkout v3 composite
- r-lib/actions/setup-pandoc v1 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/lint.yaml
actions
- actions/checkout v3 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
