-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.Rmd
More file actions
65 lines (48 loc) · 1.6 KB
/
README.Rmd
File metadata and controls
65 lines (48 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# responseFunctions
<!-- badges: start -->
[](https://github.com/PRIMER-e/responseFunctions/actions)
<!-- badges: end -->
The goal of responseFunctions is to provide a set of useful non-linear response functions with both R source-code and Stan source-code.
## Installation
You can install the development version of responseFunctions from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("PRIMER-e/responseFunctions")
```
## Example
This is a basic example which shows you how to call both the R version and Stan version of the ModSkurt function:
```{r example}
library(responseFunctions)
x <- 500
H <- 1000
m <- 750
s <- 20
r <- 0.75
d <- 50
p <- 1
# Call the R version of ModSkurt.
modskurt(x, H, m, s, r, d, p)
# Create a Stan model containing ModSkurt.
stan_model_code <- paste("functions {",
modskurt_stan[["source_code"]],
"}")
# Compile the Stan model.
model_listing <- rstan::stanc(model_code = stan_model_code)
# Expose the Stan ModSkurt function in the compiled model.
stan_function_env <- new.env()
rstan::expose_stan_functions(model_listing, env = stan_function_env)
# Call the Stan version of ModSkurt.
stan_function_env[["modskurt"]](x, H, m, s, r, d, p)
```