-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME.Rmd
142 lines (102 loc) · 4.12 KB
/
README.Rmd
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
---
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%"
)
```
# extras <a href="https://poissonconsulting.github.io/extras/"><img src="man/figures/logo.png" align="right" height="138" alt="extras website" /></a>
<!-- badges: start -->
[](https://lifecycle.r-lib.org/articles/stages.html#stable)
[](https://github.com/poissonconsulting/extras/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/poissonconsulting/extras)
[](https://cran.r-project.org/package=extras)

<!-- badges: end -->
`extras` provides helper functions for Bayesian analyses.
In particular it provides functions to summarise
vectors of MCMC (Monte Carlo Markov Chain) samples,
draw random samples from various distributions and
calculate deviance residuals as well as R translations of some
BUGS (Bayesian Using Gibbs Sampling), JAGS (Just Another Gibbs
Sampler), STAN and TMB (Template Model Builder) functions.
## Demonstration
### Summarise MCMC Samples
The `extras` package provides functions to summarise MCMC samples like `svalue()` which gives the *surprisal value* (Greenland, 2019)
```{r}
library(extras)
set.seed(1)
x <- rnorm(100)
svalue(rnorm(100))
svalue(rnorm(100, mean = 1))
svalue(rnorm(100, mean = 2))
svalue(rnorm(100, mean = 3))
```
### Distributions
Implemented distributions with functions to draw random samples, calculate log-likelihoods, and calculate deviance residuals for include:
- Bernoulli
- Binomial
- Beta-binomial
- Gamma
- Gamma-Poisson
- Zero-inflated gamma-Poisson
- Log-Normal
- Negative Binomial
- Normal
- Poisson
- Zero-inflated Poisson
- Skew Normal
- Student's t
### R translations
The package also provides R translations of `BUGS` (and `JAGS`) functions such as `pow()` and `log<-`.
```{r}
pow(10, 2)
mu <- NULL
log(mu) <- 1
mu
```
### Numericise R Objects
Atomic vectors, matrices, arrays and data.frames of appropriate classes can be converted to numeric objects suitable for Bayesian analysis using the `numericise()` (and `numericize()`) function.
```{r}
numericise(
data.frame(
logical = c(TRUE, FALSE),
factor = factor(c("blue", "green")),
Date = as.Date(c("2000-01-01", "2000-01-02")),
hms = hms::as_hms(c("00:00:02", "00:01:01"))
)
)
```
## Installation
## Information
For more information see the [Get Started](https://poissonconsulting.github.io/chk/articles/chk.html) vignette.
## Installation
### Release
To install the release version from [CRAN](https://CRAN.R-project.org/package=extras).
```r
install.packages("extras")
```
The website for the release version is at <https://poissonconsulting.github.io/extras/>.
### Development
To install the development version from [GitHub](https://github.com/poissonconsulting/extras)
```r
# install.packages("remotes")
remotes::install_github("poissonconsulting/extras")
```
or from [r-universe](https://poissonconsulting.r-universe.dev/extras).
```r
install.packages("extras", repos = c("https://poissonconsulting.r-universe.dev", "https://cloud.r-project.org"))
```
## References
Greenland, S. 2019. Valid P-Values Behave Exactly as They Should: Some Misleading Criticisms of P-Values and Their Resolution With S-Values. The American Statistician 73(sup1): 106–114.
## Contribution
Please report any [issues](https://github.com/poissonconsulting/extras/issues).
[Pull requests](https://github.com/poissonconsulting/extras/pulls) are always welcome.
## Code of Conduct
Please note that the extras project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/0/CODE_OF_CONDUCT.html).
By contributing to this project, you agree to abide by its terms.