knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

extras

Lifecycle: stable R-CMD-check Codecov test coverage CRAN status CRAN downloads

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.

Installation

install.packages("extras")

To install the developmental version from GitHub

# install.packages("remotes")
remotes::install_github("poissonconsulting/extras")

Demonstration

Summarise MCMC Samples

The extras package provides functions to summarise MCMC samples like svalue() which gives the surprisal value (Greenland, 2019)

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 include

R translations

The package also provides R translations of BUGS (and JAGS) functions such as pow() and log<-.

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.

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"))
  )
)

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. https://doi.org/10.1080/00031305.2018.1529625.

Contribution

Please report any issues.

Pull requests are always welcome.

Code of Conduct

Please note that the extras project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.



poissonconsulting/extras documentation built on Jan. 18, 2024, 1:18 a.m.