-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathREADME.Rmd
More file actions
68 lines (48 loc) · 1.83 KB
/
README.Rmd
File metadata and controls
68 lines (48 loc) · 1.83 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
66
67
68
---
output: github_document
---
<!-- README.md is generated from README.Rmd.
Please edit that file and use `devtools::build_readme()` to rebuild README.md -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# probabilityDistributions
<!-- badges: start -->
[](https://github.com/PRIMER-e/probabilityDistributions/actions)
[](https://app.codecov.io/gh/PRIMER-e/probabilityDistributions?branch=main)
<!-- badges: end -->
The goal of probabilityDistributions is to provide a library of useful
probability distributions for both R and Stan.
## Installation
You can install the development version of probabilityDistributions from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("PRIMER-e/probabilityDistributions")
```
## Example
This is a basic example which shows you how to calculate a Zero-Inflated
Poisson (ZIP) probability mass using both R and Stan:
```{r example}
library(probabilityDistributions)
library(rstan)
stan_model_code <- paste0("functions { ",
zi_poisson_lpmf_stan[["source_code"]],
" }",
sep = "\n")
model_listing <- stanc(model_code = stan_model_code)
stan_function_names <- expose_stan_functions(model_listing)
print(stan_function_names)
zi_poisson_lpmf(5, 7.5, 0.2)
dzip(5, 7.5, 0.2, log = TRUE)
```
## Development
After making changes run the following command before committing to rebuild
the package readme, which is also the home page.
```{r, eval = FALSE}
devtools::build_readme()
```