From 9ca970631254f359be2ac008b0e4f766fd2dd6c4 Mon Sep 17 00:00:00 2001 From: wlandau Date: Wed, 17 Nov 2021 20:09:15 -0500 Subject: [PATCH] Put model in README --- README.Rmd | 21 +++++++++++++++++++-- README.md | 38 ++++++++++++++++++++++++++++++-------- man/figures/model.gif | Bin 0 -> 1287 bytes 3 files changed, 49 insertions(+), 10 deletions(-) create mode 100644 man/figures/model.gif diff --git a/README.Rmd b/README.Rmd index 30e90f4..30dfe22 100644 --- a/README.Rmd +++ b/README.Rmd @@ -57,7 +57,24 @@ remotes::install_github("ropensci/jagstargets") ## Usage -First, write a [`_targets.R` file](https://books.ropensci.org/targets/walkthrough.html) that loads your packages, defines a function to generate JAGS data, and lists a pipeline of targets. The target list can call target factories like [`tar_jags()`](https://docs.ropensci.org/jagstargets/reference/tar_jags.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. +Begin with one or more models: for example, the simple regression model below with response variable $y$ and covariate $x$. + +
+ +
+ +Next, write a JAGS model file for each model like the `model.jags` file below. + +```jags +model { + for (i in 1:n) { + y[i] ~ dnorm(x[i] * beta, 1) + } + beta ~ dnorm(0, 1) +} +``` + +To begin a reproducible analysis pipeline with this model, write a [`_targets.R` file](https://books.ropensci.org/targets/walkthrough.html) that loads your packages, defines a function to generate JAGS data, and lists a pipeline of targets. The target list can call target factories like [`tar_jags()`](https://docs.ropensci.org/jagstargets/reference/tar_jags.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 @@ -74,7 +91,7 @@ generate_data <- function() { list( tar_jags( example, - jags_files = "x.jags", # You provide this file. + jags_files = "model.jags", # You provide this file. parameters.to.save = "beta", data = generate_data() ) diff --git a/README.md b/README.md index a1f97b3..b87075d 100644 --- a/README.md +++ b/README.md @@ -79,10 +79,30 @@ remotes::install_github("ropensci/jagstargets") ## Usage -First, write a [`_targets.R` -file](https://books.ropensci.org/targets/walkthrough.html) that loads -your packages, defines a function to generate JAGS data, and lists a -pipeline of targets. The target list can call target factories like +Begin with one or more models: for example, the simple regression model +below with response variable *y* and covariate *x*. + +
+ +
+ +Next, write a JAGS model file for each model like the `model.jags` file +below. + +``` jags +model { + for (i in 1:n) { + y[i] ~ dnorm(x[i] * beta, 1) + } + beta ~ dnorm(0, 1) +} +``` + +To begin a reproducible analysis pipeline with this model, write a +[`_targets.R` file](https://books.ropensci.org/targets/walkthrough.html) +that loads your packages, defines a function to generate JAGS data, and +lists a pipeline of targets. The target list can call target factories +like [`tar_jags()`](https://docs.ropensci.org/jagstargets/reference/tar_jags.html) as well as ordinary targets with [`tar_target()`](https://docs.ropensci.org/targets/reference/tar_target.html). @@ -106,7 +126,7 @@ generate_data <- function() { list( tar_jags( example, - jags_files = "x.jags", # You provide this file. + jags_files = "model.jags", # You provide this file. parameters.to.save = "beta", data = generate_data() ) @@ -173,8 +193,8 @@ citation("jagstargets") #> #> To cite package 'jagstargets' in publications use: #> -#> William Michael Landau (NA). jagstargets: Targets for JAGS Workflows. -#> https://docs.ropensci.org/jagstargets/, +#> William Michael Landau (2021). jagstargets: Targets for JAGS +#> Workflows. https://docs.ropensci.org/jagstargets/, #> https://github.com/ropensci/jagstargets. #> #> A BibTeX entry for LaTeX users is @@ -182,6 +202,8 @@ citation("jagstargets") #> @Manual{, #> title = {jagstargets: Targets for JAGS Workflows}, #> author = {William Michael Landau}, -#> note = {https://docs.ropensci.org/jagstargets/, https://github.com/ropensci/jagstargets}, +#> year = {2021}, +#> note = {https://docs.ropensci.org/jagstargets/, +#> https://github.com/ropensci/jagstargets}, #> } ``` diff --git a/man/figures/model.gif b/man/figures/model.gif new file mode 100644 index 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