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 0000000..2a2ebf1 Binary files /dev/null and b/man/figures/model.gif differ