Skip to content

Commit aaf582f

Browse files
authored
Merge pull request #15 from trackyverse/includes
Add raw stan code vignette
2 parents 35557fb + 4151839 commit aaf582f

2 files changed

Lines changed: 76 additions & 1 deletion

File tree

_pkgdown.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ reference:
3232
- model_param_ex
3333
- title: Misc
3434
contents:
35-
- TelemetrySpace-package
35+
- TelemetrySpace-package
36+

vignettes/stancode.Rmd

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
title: "Full Stan code"
3+
output: rmarkdown::html_vignette
4+
vignette: >
5+
%\VignetteIndexEntry{stancode}
6+
%\VignetteEngine{knitr::rmarkdown}
7+
%\VignetteEncoding{UTF-8}
8+
---
9+
10+
```{r, include = FALSE}
11+
knitr::opts_chunk$set(
12+
collapse = TRUE,
13+
comment = "#>"
14+
)
15+
```
16+
17+
In the course of developing TelemetrySpace, we realized that we were reusing a ton of Stan code. To make this easier on ourselves, we decided to split out the chunks we use most-often utilizing [Stan's Includes framework](https://mc-stan.org/docs/reference-manual/includes.html). This is a dream for development, but makes it kind of tough to work step-by-step through the code: before you only had to go through the file line-by-line, whereas now you have to do this while _also_ flipping between different files.
18+
19+
The following vignette serves to make things easier on you (and us!) by listing, in their completed form, the Stan code of the programs that TelemetrySpace uses.
20+
21+
```{r setup}
22+
library(TelemetrySpace)
23+
```
24+
25+
The Stan models used in TelemetrySpace are stored in a non-exported list [created by `rstantools`](https://mc-stan.org/rstantools/reference/use_rstan.html#using-the-pre-compiled-stan-programs-in-your-package), `stanmodels`. Each element of the list contains the knitted-together Stan code we're looking for. We can access the code like so:
26+
```{r eval=-2}
27+
stanmodels <- TelemetrySpace:::stanmodels
28+
stanmodels$COA_Standard_gaussian
29+
```
30+
31+
This code will be hidden for the rest of the vignette, but feel free to poke around in the package yourself.
32+
33+
## COA Standard
34+
35+
### Gaussian transmitter signal decay
36+
`COA_Standard(...)` or `COA_Standard(..., decay = "gaussian")`:
37+
```{r echo=FALSE}
38+
stanmodels$COA_Standard_gaussian
39+
```
40+
41+
### Logistic transmitter signal decay
42+
`COA_Standard(..., decay = "logistic")`:
43+
```{r echo=FALSE}
44+
stanmodels$COA_Standard_logistic
45+
```
46+
47+
## COA Time Varying
48+
49+
### Gaussian transmitter signal decay
50+
`COA_TimeVarying(...)` or `COA_TimeVarying(..., decay = "gaussian")`
51+
```{r echo=FALSE}
52+
stanmodels$COA_TimeVarying_gaussian
53+
```
54+
55+
### Logistic transmitter signal decay
56+
`COA_TimeVarying(..., decay = "logistic")`:
57+
```{r echo=FALSE}
58+
stanmodels$COA_TimeVarying_logistic
59+
```
60+
61+
62+
## COA Tag-Itegrated
63+
64+
### Gaussian transmitter signal decay
65+
`COA_TagInt(...)` or `COA_TagInt(..., decay = "gaussian")`:
66+
```{r echo=FALSE}
67+
stanmodels$COA_Tag_Integrated_gaussian
68+
```
69+
70+
### Logistic transmitter signal decay
71+
`COA_TagInt(..., decay = "logistic")`:
72+
```{r echo=FALSE}
73+
stanmodels$COA_Tag_Integrated_logistic
74+
```

0 commit comments

Comments
 (0)