| Title: | Helper Functions for Bayesian Analyses |
|---|---|
| Description: | Functions to 'numericise' 'R' objects (coerce to numeric objects), summarise 'MCMC' (Monte Carlo Markov Chain) samples 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. |
| Authors: | Nicole Hill [aut, cre] (ORCID: <https://orcid.org/0000-0002-7623-2153>), Joe Thorley [aut] (ORCID: <https://orcid.org/0000-0002-7683-4592>), Kirill Müller [ctb] (ORCID: <https://orcid.org/0000-0002-1416-3412>), Nadine Hussein [ctb] (ORCID: <https://orcid.org/0000-0003-4470-8361>), Stefano Mezzini [ctb] (ORCID: <https://orcid.org/0000-0001-8551-7436>), Poisson Consulting [cph, fnd] |
| Maintainer: | Nicole Hill <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.9.0.9003 |
| Built: | 2026-06-26 10:25:32 UTC |
| Source: | https://github.com/poissonconsulting/extras |
Coerces an object to an list. All attributes are removed except any names.
as_list(x, ...) ## Default S3 method: as_list(x, ...)as_list(x, ...) ## Default S3 method: as_list(x, ...)
x |
An object. |
... |
Other arguments passed to methods. |
A list.
as_list(1:3) as_list(c(x = 1, y = 2))as_list(1:3) as_list(c(x = 1, y = 2))
Coerces an object to an list. All attributes are removed except any names.
as_list_unnamed(x, ...) ## Default S3 method: as_list_unnamed(x, ...)as_list_unnamed(x, ...) ## Default S3 method: as_list_unnamed(x, ...)
x |
An object. |
... |
Other arguments passed to methods. |
A list.
as_list_unnamed(1:3) as_list_unnamed(c(x = 1, y = 2))as_list_unnamed(1:3) as_list_unnamed(c(x = 1, y = 2))
Checks if an object is a vector of one or more positive integer values.
chk_index(x, x_name = NULL) vld_index(x)chk_index(x, x_name = NULL) vld_index(x)
x |
An object. |
x_name |
A string of the name of object x or NULL. |
The chk_ function throws an informative error if the test fails.
The vld_ function returns a flag indicating whether the test was met.
vld_index(): Validate Index
x <- c(2L, 1L) chk_index(x) y <- c(2L, -1L) try(chk_index(y)) vld_index(c(-1)) vld_index(c(3L, 1L))x <- c(2L, 1L) chk_index(x) y <- c(2L, -1L) try(chk_index(y)) vld_index(c(-1)) vld_index(c(3L, 1L))
Checks if an object is a list of indices ie vectors of one or more positive integer values.
chk_indices(x, x_name = NULL) vld_indices(x)chk_indices(x, x_name = NULL) vld_indices(x)
x |
An object. |
x_name |
A string of the name of object x or NULL. |
The chk_ function throws an informative error if the test fails.
The vld_ function returns a flag indicating whether the test was met.
vld_indices(): Validate Indices
x <- list(c(2L, 1L)) chk_indices(x) y <- c(2L, 1L) try(chk_indices(y)) vld_indices(c(3L, 1L)) vld_indices(list(c(3L, 1L)))x <- list(c(2L, 1L)) chk_indices(x) y <- c(2L, 1L) try(chk_indices(y)) vld_indices(c(3L, 1L)) vld_indices(list(c(3L, 1L)))
Checks if valid parameter names.
chk_pars(x, x_name = NULL) vld_pars(x)chk_pars(x, x_name = NULL) vld_pars(x)
x |
An object. |
x_name |
A string of the name of object x or NULL. |
The character vector must consist of values that start with an alpha and only include alphanumeric characters and '_' or '.'.
Missing values and duplicates are permitted.
The chk_ function throws an informative error if the test fails.
The vld_ function returns a flag indicating whether the test was met.
vld_pars(): Validate Parameter Names
x <- c("x", "a1._", "X") chk_pars(x) y <- c("x[1]", "a1", "a1", "._0") try(chk_pars(y)) vld_pars(c("x", "a1._", "X")) vld_pars(c("x[1]", "a1", "a1", "._0"))x <- c("x", "a1._", "X") chk_pars(x) y <- c("x[1]", "a1", "a1", "._0") try(chk_pars(y)) vld_pars(c("x", "a1._", "X")) vld_pars(c("x[1]", "a1", "a1", "._0"))
Bernoulli Distribution
dbern(x, prob, log = FALSE) pbern(q, prob, lower.tail = TRUE, log = FALSE) qbern(p, prob, lower.tail = TRUE, log = FALSE) rbern(n, prob)dbern(x, prob, log = FALSE) pbern(q, prob, lower.tail = TRUE, log = FALSE) qbern(p, prob, lower.tail = TRUE, log = FALSE) rbern(n, prob)
x |
A vector of 0s and 1s. |
prob |
A numeric vector of values between 0 and 1 of the probability of success. |
log |
A flag specifying whether to return the log-transformed value. |
q |
A vector of quantiles. |
lower.tail |
A flag specifying whether to return the lower or upper tail of the distribution. |
p |
A numeric vector of probabilities. |
n |
A non-negative whole number of the number of random samples to generate. |
An numeric vector of the random samples.
dbern(1, 0.5) pbern(0.75, 0.5) qbern(0.1, 0.5) rbern(1, 0.5)dbern(1, 0.5) pbern(0.75, 0.5) qbern(0.1, 0.5) rbern(1, 0.5)
Bernoulli Deviances
dev_bern(x, prob = 0.5, res = FALSE)dev_bern(x, prob = 0.5, res = FALSE)
x |
A vector of 0s and 1s. |
prob |
A numeric vector of values between 0 and 1 of the probability of success. |
res |
A flag specifying whether to return the deviance residual as opposed to the deviance. |
An numeric vector of the corresponding deviances or deviance residuals.
Other dev_dist:
dev_beta_binom(),
dev_binom(),
dev_gamma(),
dev_gamma_pois(),
dev_lnorm(),
dev_neg_binom(),
dev_norm(),
dev_pois(),
dev_pois_zi(),
dev_skewnorm(),
dev_student()
dev_bern(c(TRUE, FALSE), 0.7)dev_bern(c(TRUE, FALSE), 0.7)
This parameterization of the beta-binomial distribution uses an expected
probability parameter, prob, and a dispersion parameter, theta. The
parameters of the underlying beta mixture are alpha = (2 * prob) / theta
and beta = (2 * (1 - prob)) / theta. This parameterization of theta is
unconventional, but has useful properties when modelling. When theta = 0,
the beta-binomial reverts to the binomial distribution. When theta = 1 and
prob = 0.5, the parameters of the beta distribution become alpha = 1 and
beta = 1, which correspond to a uniform distribution for the beta-binomial
probability parameter.
dev_beta_binom(x, size = 1, prob = 0.5, theta = 0, res = FALSE)dev_beta_binom(x, size = 1, prob = 0.5, theta = 0, res = FALSE)
x |
A non-negative whole numeric vector of values. |
size |
A non-negative whole numeric vector of the number of trials. |
prob |
A numeric vector of values between 0 and 1 of the probability of success. |
theta |
A non-negative numeric vector of the dispersion for the mixture models (student, gamma-Poisson and beta-binomial). |
res |
A flag specifying whether to return the deviance residual as opposed to the deviance. |
An numeric vector of the corresponding deviances or deviance residuals.
Other dev_dist:
dev_bern(),
dev_binom(),
dev_gamma(),
dev_gamma_pois(),
dev_lnorm(),
dev_neg_binom(),
dev_norm(),
dev_pois(),
dev_pois_zi(),
dev_skewnorm(),
dev_student()
dev_beta_binom(c(0, 1, 2), 10, 0.5, 0.1)dev_beta_binom(c(0, 1, 2), 10, 0.5, 0.1)
Binomial Deviances
dev_binom(x, size = 1, prob = 0.5, res = FALSE)dev_binom(x, size = 1, prob = 0.5, res = FALSE)
x |
A non-negative whole numeric vector of values. |
size |
A non-negative whole numeric vector of the number of trials. |
prob |
A numeric vector of values between 0 and 1 of the probability of success. |
res |
A flag specifying whether to return the deviance residual as opposed to the deviance. |
An numeric vector of the corresponding deviances or deviance residuals.
Other dev_dist:
dev_bern(),
dev_beta_binom(),
dev_gamma(),
dev_gamma_pois(),
dev_lnorm(),
dev_neg_binom(),
dev_norm(),
dev_pois(),
dev_pois_zi(),
dev_skewnorm(),
dev_student()
dev_binom(c(0, 1, 2), 2, 0.3)dev_binom(c(0, 1, 2), 2, 0.3)
Gamma Deviances
dev_gamma(x, shape = 1, rate = 1, res = FALSE)dev_gamma(x, shape = 1, rate = 1, res = FALSE)
x |
A numeric vector of values. |
shape |
A non-negative numeric vector of shape. |
rate |
A non-negative numeric vector of rate. |
res |
A flag specifying whether to return the deviance residual as opposed to the deviance. |
An numeric vector of the corresponding deviances or deviance residuals.
Other dev_dist:
dev_bern(),
dev_beta_binom(),
dev_binom(),
dev_gamma_pois(),
dev_lnorm(),
dev_neg_binom(),
dev_norm(),
dev_pois(),
dev_pois_zi(),
dev_skewnorm(),
dev_student()
dev_gamma(c(0, 1, 2), 1, 2)dev_gamma(c(0, 1, 2), 1, 2)
Gamma-Poisson Deviances
dev_gamma_pois(x, lambda = 1, theta = 0, res = FALSE)dev_gamma_pois(x, lambda = 1, theta = 0, res = FALSE)
x |
A non-negative whole numeric vector of values. |
lambda |
A non-negative numeric vector of means. |
theta |
A non-negative numeric vector of the dispersion for the mixture models (student, gamma-Poisson and beta-binomial). |
res |
A flag specifying whether to return the deviance residual as opposed to the deviance. |
An numeric vector of the corresponding deviances or deviance residuals.
Other dev_dist:
dev_bern(),
dev_beta_binom(),
dev_binom(),
dev_gamma(),
dev_lnorm(),
dev_neg_binom(),
dev_norm(),
dev_pois(),
dev_pois_zi(),
dev_skewnorm(),
dev_student()
dev_gamma_pois(c(1, 3, 4), 3, 2)dev_gamma_pois(c(1, 3, 4), 3, 2)
Zero-Inflated Gamma-Poisson Deviances
dev_gamma_pois_zi(x, lambda = 1, theta = 0, prob = 0, res = FALSE)dev_gamma_pois_zi(x, lambda = 1, theta = 0, prob = 0, res = FALSE)
x |
A non-negative whole numeric vector of values. |
lambda |
A non-negative numeric vector of means. |
theta |
A non-negative numeric vector of the dispersion for the mixture models (student, gamma-Poisson and beta-binomial). |
prob |
A numeric vector of values between 0 and 1 of the probability of success. |
res |
A flag specifying whether to return the deviance residual as opposed to the deviance. |
An numeric vector of the corresponding deviances or deviance residuals.
dev_gamma_pois_zi(c(1, 3, 4), 3, 2)dev_gamma_pois_zi(c(1, 3, 4), 3, 2)
Log-Normal Deviances
dev_lnorm(x, meanlog = 0, sdlog = 1, res = FALSE)dev_lnorm(x, meanlog = 0, sdlog = 1, res = FALSE)
x |
A numeric vector of values. |
meanlog |
A numeric vector of the means on the log scale. |
sdlog |
A non-negative numeric vector of the standard deviations on the log scale. |
res |
A flag specifying whether to return the deviance residual as opposed to the deviance. |
An numeric vector of the corresponding deviances or deviance residuals.
Other dev_dist:
dev_bern(),
dev_beta_binom(),
dev_binom(),
dev_gamma(),
dev_gamma_pois(),
dev_neg_binom(),
dev_norm(),
dev_pois(),
dev_pois_zi(),
dev_skewnorm(),
dev_student()
dev_lnorm(exp(-2:2))dev_lnorm(exp(-2:2))
Negative Binomial Deviances
dev_neg_binom(x, lambda = 1, theta = 0, res = FALSE)dev_neg_binom(x, lambda = 1, theta = 0, res = FALSE)
x |
A non-negative whole numeric vector of values. |
lambda |
A non-negative numeric vector of means. |
theta |
A non-negative numeric vector of the dispersion for the mixture models (student, gamma-Poisson and beta-binomial). |
res |
A flag specifying whether to return the deviance residual as opposed to the deviance. |
An numeric vector of the corresponding deviances or deviance residuals.
Other dev_dist:
dev_bern(),
dev_beta_binom(),
dev_binom(),
dev_gamma(),
dev_gamma_pois(),
dev_lnorm(),
dev_norm(),
dev_pois(),
dev_pois_zi(),
dev_skewnorm(),
dev_student()
dev_neg_binom(c(1, 2, 5), 2, 3)dev_neg_binom(c(1, 2, 5), 2, 3)
Normal Deviances
dev_norm(x, mean = 0, sd = 1, res = FALSE)dev_norm(x, mean = 0, sd = 1, res = FALSE)
x |
A numeric vector of values. |
mean |
A numeric vector of the means. |
sd |
A non-negative numeric vector of the standard deviations. |
res |
A flag specifying whether to return the deviance residual as opposed to the deviance. |
An numeric vector of the corresponding deviances or deviance residuals.
Other dev_dist:
dev_bern(),
dev_beta_binom(),
dev_binom(),
dev_gamma(),
dev_gamma_pois(),
dev_lnorm(),
dev_neg_binom(),
dev_pois(),
dev_pois_zi(),
dev_skewnorm(),
dev_student()
dev_norm(c(-2:2))dev_norm(c(-2:2))
Poisson Deviances
dev_pois(x, lambda, res = FALSE)dev_pois(x, lambda, res = FALSE)
x |
A non-negative whole numeric vector of values. |
lambda |
A non-negative numeric vector of means. |
res |
A flag specifying whether to return the deviance residual as opposed to the deviance. |
An numeric vector of the corresponding deviances or deviance residuals.
Other dev_dist:
dev_bern(),
dev_beta_binom(),
dev_binom(),
dev_gamma(),
dev_gamma_pois(),
dev_lnorm(),
dev_neg_binom(),
dev_norm(),
dev_pois_zi(),
dev_skewnorm(),
dev_student()
dev_pois(c(1, 3, 4), 3)dev_pois(c(1, 3, 4), 3)
Zero-Inflated Poisson Deviances
dev_pois_zi(x, lambda, prob = 0, res = FALSE)dev_pois_zi(x, lambda, prob = 0, res = FALSE)
x |
A non-negative whole numeric vector of values. |
lambda |
A non-negative numeric vector of means. |
prob |
A numeric vector of values between 0 and 1 of the probability of success. |
res |
A flag specifying whether to return the deviance residual as opposed to the deviance. |
An numeric vector of the corresponding deviances or deviance residuals.
Other dev_dist:
dev_bern(),
dev_beta_binom(),
dev_binom(),
dev_gamma(),
dev_gamma_pois(),
dev_lnorm(),
dev_neg_binom(),
dev_norm(),
dev_pois(),
dev_skewnorm(),
dev_student()
dev_pois_zi(c(1, 3, 4), 3)dev_pois_zi(c(1, 3, 4), 3)
Skew Normal Deviances
dev_skewnorm(x, mean = 0, sd = 1, shape = 0, res = FALSE)dev_skewnorm(x, mean = 0, sd = 1, shape = 0, res = FALSE)
x |
A numeric vector of values. |
mean |
A numeric vector of the means. |
sd |
A non-negative numeric vector of the standard deviations. |
shape |
A numeric vector of shape. |
res |
A flag specifying whether to return the deviance residual as opposed to the deviance. |
An numeric vector of the corresponding deviances or deviance residuals.
Other dev_dist:
dev_bern(),
dev_beta_binom(),
dev_binom(),
dev_gamma(),
dev_gamma_pois(),
dev_lnorm(),
dev_neg_binom(),
dev_norm(),
dev_pois(),
dev_pois_zi(),
dev_student()
dev_skewnorm(c(-2:2)) dev_skewnorm(-2:2, 0, 1, 5) dev_skewnorm(-2:2, 0, 1, 5, res = TRUE)dev_skewnorm(c(-2:2)) dev_skewnorm(-2:2, 0, 1, 5) dev_skewnorm(-2:2, 0, 1, 5, res = TRUE)
Student's t Deviances
dev_student(x, mean = 0, sd = 1, theta = 0, res = FALSE)dev_student(x, mean = 0, sd = 1, theta = 0, res = FALSE)
x |
A numeric vector of values. |
mean |
A numeric vector of the means. |
sd |
A non-negative numeric vector of the standard deviations. |
theta |
A non-negative numeric vector of the dispersion for the mixture models (student, gamma-Poisson and beta-binomial). |
res |
A flag specifying whether to return the deviance residual as opposed to the deviance. |
An numeric vector of the corresponding deviances or deviance residuals.
Other dev_dist:
dev_bern(),
dev_beta_binom(),
dev_binom(),
dev_gamma(),
dev_gamma_pois(),
dev_lnorm(),
dev_neg_binom(),
dev_norm(),
dev_pois(),
dev_pois_zi(),
dev_skewnorm()
dev_student(c(1, 3.5, 4), 3)dev_student(c(1, 3.5, 4), 3)
The direction of a distribution is the side (left/right) that the distribution's center falls on, relative to a threshold. The center can be calculated using a user-specified function, including the median (default), mean, geometric mean, mode, or any other custom function. By convention, values below the threshold fall to the left, while values above the threshold fall to the right. Center estimates equal to the threshold are assumed to fall to the right.
direction(x, estimate = xtr_median, threshold = 0, na_rm = FALSE)direction(x, estimate = xtr_median, threshold = 0, na_rm = FALSE)
x |
A numeric vector of MCMC values or any other numeric vector of samples. |
estimate |
A function for estimating the center of the distribution.
Defaults to |
threshold |
A number of the threshold value. |
na_rm |
A flag specifying whether to remove missing values. |
A string indicating if at least half of the observations are above
the threshold ("right") or not ("left"), or NA_character_ in the case
of missing values when na_rm = FALSE.
Other summary:
directional_information(),
kurtosis(),
lower(),
probability_direction(),
pvalue(),
pzeros(),
skewness(),
svalue(),
upper(),
variance(),
xtr_mean(),
xtr_median(),
xtr_sd(),
zeros(),
zscore()
direction(c(1, 2, 3)) direction(c(-1)) direction(c(0, 0, 0)) direction(c(-100, 1, 1)) direction(c(-100, 1, 1), mean) direction(c(100, 0.01, 0.01), function(.x) exp(mean(log(.x))))direction(c(1, 2, 3)) direction(c(-1)) direction(c(0, 0, 0)) direction(c(-100, 1, 1)) direction(c(-100, 1, 1), mean) direction(c(100, 0.01, 0.01), function(.x) exp(mean(log(.x))))
The occurrence of an event (or lack thereof) transmits more or less information depending on the event's probability.
directional_information( x, side = "median", threshold = 0, threshold_split = "proportional", na_rm = FALSE ) p2info(p, n = Inf)directional_information( x, side = "median", threshold = 0, threshold_split = "proportional", na_rm = FALSE ) p2info(p, n = Inf)
x |
A numeric vector of MCMC values. |
side |
A string indicating whether to calculate
the directional information relative to the left side ( |
threshold |
A number of the threshold value. |
threshold_split |
A string indicating how to deal with threshold values:
|
na_rm |
A flag specifying whether to remove missing values. |
p |
A numeric vector of probabilities of direction. |
n |
A numeric vector of the number of posterior samples used to estimate
each value of |
Quantifies the information about direction in a posterior distribution based on the directional probability.
This function calculates such information using the difference in the probability of direction (see probability_direction()), after converting each probability to bits (also see svalue().
A number indicating the directional information in bits.
If x has NA values but na_rm is FALSE, returns NA_real.
directional_information(): Calculate the directional information from a posterior distribution.
p2info(): Calculate the information from a vector of probabilities.
Kery, M., and Schaub, M. 2011. Bayesian population analysis using WinBUGS: a hierarchical perspective. Academic Press, Boston. Available from https://www.vogelwarte.ch/en/research/population-biology/book-bpa/.
Other summary:
direction(),
kurtosis(),
lower(),
probability_direction(),
pvalue(),
pzeros(),
skewness(),
svalue(),
upper(),
variance(),
xtr_mean(),
xtr_median(),
xtr_sd(),
zeros(),
zscore()
directional_information(0) directional_information(1) # one coin flip of information directional_information(c(1, 1)) # two coin flips directional_information(c(1, 1, -1)) # x[2] and x[3] cancel out directional_information(c(1, 1, -1, -1)) # both sides cancel out directional_information(rnorm(1e3, mean = 0)) directional_information(rnorm(1e3, mean = 1)) directional_information(rnorm(1e3, mean = 10)) # all coin flips are positive directional_information(rnorm(1e3, mean = -10)) # all coin flips are negative directional_information(rnorm(1e3, mean = 1e3)) # only quantiles matter directional_information(rnorm(1e6, mean = 1e3)) # more `x` implies more info p2info(seq(0, 1, by = 0.1)) p2info(seq(0, 1, by = 0.1), n = 10) # limit information to be in [-10, 10]directional_information(0) directional_information(1) # one coin flip of information directional_information(c(1, 1)) # two coin flips directional_information(c(1, 1, -1)) # x[2] and x[3] cancel out directional_information(c(1, 1, -1, -1)) # both sides cancel out directional_information(rnorm(1e3, mean = 0)) directional_information(rnorm(1e3, mean = 1)) directional_information(rnorm(1e3, mean = 10)) # all coin flips are positive directional_information(rnorm(1e3, mean = -10)) # all coin flips are negative directional_information(rnorm(1e3, mean = 1e3)) # only quantiles matter directional_information(rnorm(1e6, mean = 1e3)) # more `x` implies more info p2info(seq(0, 1, by = 0.1)) p2info(seq(0, 1, by = 0.1), n = 10) # limit information to be in [-10, 10]
Skew-Normal Distribution
dskewnorm(x, mean = 0, sd = 1, shape = 0, log = FALSE) pskewnorm(q, mean = 0, sd = 1, shape = 0) qskewnorm(p, mean = 0, sd = 1, shape = 0) rskewnorm(n = 1, mean = 0, sd = 1, shape = 0)dskewnorm(x, mean = 0, sd = 1, shape = 0, log = FALSE) pskewnorm(q, mean = 0, sd = 1, shape = 0) qskewnorm(p, mean = 0, sd = 1, shape = 0) rskewnorm(n = 1, mean = 0, sd = 1, shape = 0)
x |
A numeric vector of values. |
mean |
A numeric vector of the means. |
sd |
A non-negative numeric vector of the standard deviations. |
shape |
A numeric vector of values. |
log |
A flag specifying whether to return the log-transformed value. |
q |
A vector of quantiles. |
p |
A numeric vector of probabilities. |
n |
A non-negative whole number of the number of random samples to generate. |
dskewnorm gives the density, pskewnorm gives the distribution function, qskewnorm gives the quantile function, and rskewnorm generates random deviates.
pskewnorm and qskewnorm use the lower tail probability.
dskewnorm(x = -2:2, mean = 0, sd = 1, shape = 0.1) dskewnorm(x = -2:2, mean = 0, sd = 1, shape = -1) qskewnorm(p = c(0.1, 0.4), mean = 0, sd = 1, shape = 0.1) qskewnorm(p = c(0.1, 0.4), mean = 0, sd = 1, shape = -1) pskewnorm(q = -2:2, mean = 0, sd = 1, shape = 0.1) pskewnorm(q = -2:2, mean = 0, sd = 1, shape = -1) rskewnorm(n = 3, mean = 0, sd = 1, shape = 0.1) rskewnorm(n = 3, mean = 0, sd = 1, shape = -1)dskewnorm(x = -2:2, mean = 0, sd = 1, shape = 0.1) dskewnorm(x = -2:2, mean = 0, sd = 1, shape = -1) qskewnorm(p = c(0.1, 0.4), mean = 0, sd = 1, shape = 0.1) qskewnorm(p = c(0.1, 0.4), mean = 0, sd = 1, shape = -1) pskewnorm(q = -2:2, mean = 0, sd = 1, shape = 0.1) pskewnorm(q = -2:2, mean = 0, sd = 1, shape = -1) rskewnorm(n = 3, mean = 0, sd = 1, shape = 0.1) rskewnorm(n = 3, mean = 0, sd = 1, shape = -1)
Returns the transformation of 10^x.
exp10(x)exp10(x)
x |
An numeric atomic object. |
A numeric atomic object with the value of 10^x.
Other translations:
exp2(),
fabs(),
ilog(),
ilog10(),
ilog2(),
ilogit(),
inv_logit(),
invlogit(),
log10<-(),
log2<-(),
log<-(),
logit(),
logit<-(),
phi(),
pow(),
step()
x <- c(5, 10.5) exp10(x)x <- c(5, 10.5) exp10(x)
Returns the transformation of 2^x.
exp2(x)exp2(x)
x |
An numeric atomic object. |
A numeric atomic object with the value of 2^x.
Other translations:
exp10(),
fabs(),
ilog(),
ilog10(),
ilog2(),
ilogit(),
inv_logit(),
invlogit(),
log10<-(),
log2<-(),
log<-(),
logit(),
logit<-(),
phi(),
pow(),
step()
x <- c(5, 10.5) exp2(x)x <- c(5, 10.5) exp2(x)
Computes the absolute value of x.
Used in TMB as replacement for abs() which is seemingly ambiguous.
fabs(x)fabs(x)
x |
An existing R object. |
A wrapper on abs().
A numeric vector of the corresponding absolute values.
Other translations:
exp10(),
exp2(),
ilog(),
ilog10(),
ilog2(),
ilogit(),
inv_logit(),
invlogit(),
log10<-(),
log2<-(),
log<-(),
logit(),
logit<-(),
phi(),
pow(),
step()
fabs(c(0, -1, 2))fabs(c(0, -1, 2))
Fills all of an object's (missing and non-missing) values while preserving the object's dimensionality and class.
fill_all(x, value, ...) ## S3 method for class 'logical' fill_all(x, value = FALSE, nas = TRUE, ...) ## S3 method for class 'integer' fill_all(x, value = 0L, nas = TRUE, ...) ## S3 method for class 'numeric' fill_all(x, value = 0, nas = TRUE, ...) ## S3 method for class 'character' fill_all(x, value = "0", nas = TRUE, ...)fill_all(x, value, ...) ## S3 method for class 'logical' fill_all(x, value = FALSE, nas = TRUE, ...) ## S3 method for class 'integer' fill_all(x, value = 0L, nas = TRUE, ...) ## S3 method for class 'numeric' fill_all(x, value = 0, nas = TRUE, ...) ## S3 method for class 'character' fill_all(x, value = "0", nas = TRUE, ...)
x |
An object. |
value |
A scalar of the value to replace values with. |
... |
Other arguments passed to methods. |
nas |
A flag specifying whether to also fill missing values. |
It should only be defined for objects with values of consistent class ie not standard data.frames.
The modified object.
fill_all(logical): Fill All for logical Objects
fill_all(integer): Fill All for integer Objects
fill_all(numeric): Fill All for numeric Objects
fill_all(character): Fill All for character Objects
Other fill:
fill_na()
# logical fill_all(c(TRUE, NA, FALSE)) fill_all(c(TRUE, NA, FALSE, nas = FALSE)) fill_all(c(TRUE, NA, FALSE, value = NA)) # integer fill_all(matrix(1:4, nrow = 2), value = -1) # numeric fill_all(c(1, 4, NA), value = TRUE) fill_all(c(1, 4, NA), value = TRUE, nas = FALSE) # character fill_all(c("some", "words"), value = TRUE)# logical fill_all(c(TRUE, NA, FALSE)) fill_all(c(TRUE, NA, FALSE, nas = FALSE)) fill_all(c(TRUE, NA, FALSE, value = NA)) # integer fill_all(matrix(1:4, nrow = 2), value = -1) # numeric fill_all(c(1, 4, NA), value = TRUE) fill_all(c(1, 4, NA), value = TRUE, nas = FALSE) # character fill_all(c("some", "words"), value = TRUE)
Fills all of an object's missing values while preserving the object's dimensionality and class.
fill_na(x, value, ...) ## S3 method for class 'logical' fill_na(x, value = FALSE, ...) ## S3 method for class 'integer' fill_na(x, value = 0L, ...) ## S3 method for class 'numeric' fill_na(x, value = 0, ...) ## S3 method for class 'character' fill_na(x, value = "0", ...)fill_na(x, value, ...) ## S3 method for class 'logical' fill_na(x, value = FALSE, ...) ## S3 method for class 'integer' fill_na(x, value = 0L, ...) ## S3 method for class 'numeric' fill_na(x, value = 0, ...) ## S3 method for class 'character' fill_na(x, value = "0", ...)
x |
An object. |
value |
A scalar of the value to replace values with. |
... |
Other arguments passed to methods. |
It should only be defined for objects with values of consistent class ie not standard data.frames.
The modified object.
fill_na(logical): Fill Missing Values for logical Objects
fill_na(integer): Fill Missing Values for integer Objects
fill_na(numeric): Fill Missing Values for numeric Objects
fill_na(character): Fill Missing Values for character Objects
Other fill:
fill_all()
# logical fill_na(c(TRUE, NA)) # integer fill_na(c(1L, NA), 0) # numeric fill_na(c(1, NA), Inf) # character fill_na(c("text", NA)) fill_na(matrix(c("text", NA)), value = Inf)# logical fill_na(c(TRUE, NA)) # integer fill_na(c(1L, NA), 0) # numeric fill_na(c(1, NA), Inf) # character fill_na(c("text", NA)) fill_na(matrix(c("text", NA)), value = Inf)
Inverse log transforms a numeric atomic object.
ilog(x)ilog(x)
x |
An object. |
A wrapper on exp(value).
A numeric atomic object.
Other translations:
exp10(),
exp2(),
fabs(),
ilog10(),
ilog2(),
ilogit(),
inv_logit(),
invlogit(),
log10<-(),
log2<-(),
log<-(),
logit(),
logit<-(),
phi(),
pow(),
step()
x <- 1 ilog(x)x <- 1 ilog(x)
Inverse log transforms a numeric atomic object with base 10.
ilog10(x)ilog10(x)
x |
An object. |
A wrapper on exp10(value).
A numeric atomic object.
Other translations:
exp10(),
exp2(),
fabs(),
ilog(),
ilog2(),
ilogit(),
inv_logit(),
invlogit(),
log10<-(),
log2<-(),
log<-(),
logit(),
logit<-(),
phi(),
pow(),
step()
x <- c(2, 4.5) ilog10(x)x <- c(2, 4.5) ilog10(x)
Inverse log transforms a numeric atomic object with base 2.
ilog2(x)ilog2(x)
x |
An object. |
A wrapper on exp2(value).
A numeric atomic object.
Other translations:
exp10(),
exp2(),
fabs(),
ilog(),
ilog10(),
ilogit(),
inv_logit(),
invlogit(),
log10<-(),
log2<-(),
log<-(),
logit(),
logit<-(),
phi(),
pow(),
step()
x <- c(2, 4.5) ilog2(x)x <- c(2, 4.5) ilog2(x)
Inverse logistically transforms a numeric atomic object.
ilogit(x)ilogit(x)
x |
A numeric atomic object. |
A wrapper on stats::plogis().
A numeric atomic object.
Other translations:
exp10(),
exp2(),
fabs(),
ilog(),
ilog10(),
ilog2(),
inv_logit(),
invlogit(),
log10<-(),
log2<-(),
log<-(),
logit(),
logit<-(),
phi(),
pow(),
step()
ilogit(c(-1, 0, 5))ilogit(c(-1, 0, 5))
Inverse logistically transforms a numeric atomic object.
inv_logit(x)inv_logit(x)
x |
A numeric atomic object. |
A wrapper on stats::plogis().
A numeric atomic object.
Other translations:
exp10(),
exp2(),
fabs(),
ilog(),
ilog10(),
ilog2(),
ilogit(),
invlogit(),
log10<-(),
log2<-(),
log<-(),
logit(),
logit<-(),
phi(),
pow(),
step()
inv_logit(c(-1, 0, 5))inv_logit(c(-1, 0, 5))
Calculates the probabilities for odds.
inv_odds(x)inv_odds(x)
x |
A numeric object (vector, matrix or array) of odds. |
A numeric object of the the probabilities for each odd.
Other odds:
log_odds(),
log_odds<-(),
log_odds_ratio(),
odds(),
odds<-(),
odds_ratio()
inv_odds(c(0, 1, 9, 9999))inv_odds(c(0, 1, 9, 9999))
Inverse logistically transforms a numeric atomic object.
invlogit(x)invlogit(x)
x |
A numeric atomic object. |
A wrapper on stats::plogis().
A numeric atomic object.
Other translations:
exp10(),
exp2(),
fabs(),
ilog(),
ilog10(),
ilog2(),
ilogit(),
inv_logit(),
log10<-(),
log2<-(),
log<-(),
logit(),
logit<-(),
phi(),
pow(),
step()
invlogit(c(-1, 0, 5))invlogit(c(-1, 0, 5))
Kurtosis
kurtosis(x, na_rm = FALSE)kurtosis(x, na_rm = FALSE)
x |
A numeric object of MCMC values. |
na_rm |
A flag specifying whether to remove missing values. |
A number.
Other summary:
direction(),
directional_information(),
lower(),
probability_direction(),
pvalue(),
pzeros(),
skewness(),
svalue(),
upper(),
variance(),
xtr_mean(),
xtr_median(),
xtr_sd(),
zeros(),
zscore()
kurtosis(1:10)kurtosis(1:10)
Bernoulli Log-Likelihood
log_lik_bern(x, prob = 0.5)log_lik_bern(x, prob = 0.5)
x |
A vector of 0s and 1s. |
prob |
A numeric vector of values between 0 and 1 of the probability of success. |
An numeric vector of the corresponding log-likelihoods.
Other log_lik_dist:
log_lik_beta(),
log_lik_beta_binom(),
log_lik_binom(),
log_lik_exp(),
log_lik_gamma(),
log_lik_gamma_pois(),
log_lik_gamma_pois_zi(),
log_lik_lnorm(),
log_lik_neg_binom(),
log_lik_norm(),
log_lik_pois(),
log_lik_pois_zi(),
log_lik_skewnorm(),
log_lik_student(),
log_lik_unif()
log_lik_bern(c(TRUE, FALSE), 0.7)log_lik_bern(c(TRUE, FALSE), 0.7)
Beta Log-Likelihood
log_lik_beta(x, alpha = 1, beta = 1, tlower = 0, tupper = 1)log_lik_beta(x, alpha = 1, beta = 1, tlower = 0, tupper = 1)
x |
A vector of values between 0s and 1s. |
alpha |
The first shape parameter of the beta distribution. |
beta |
The second shape parameter of the beta distribution. |
tlower |
A numeric vector of the lower truncation point. |
tupper |
A numeric vector of the upper truncation point. |
An numeric vector of the corresponding log-likelihoods.
Other log_lik_dist:
log_lik_bern(),
log_lik_beta_binom(),
log_lik_binom(),
log_lik_exp(),
log_lik_gamma(),
log_lik_gamma_pois(),
log_lik_gamma_pois_zi(),
log_lik_lnorm(),
log_lik_neg_binom(),
log_lik_norm(),
log_lik_pois(),
log_lik_pois_zi(),
log_lik_skewnorm(),
log_lik_student(),
log_lik_unif()
log_lik_beta(c(0, 0.5, 0.7, 1), 0.7)log_lik_beta(c(0, 0.5, 0.7, 1), 0.7)
This parameterization of the beta-binomial distribution uses an expected
probability parameter, prob, and a dispersion parameter, theta. The
parameters of the underlying beta mixture are alpha = (2 * prob) / theta
and beta = (2 * (1 - prob)) / theta. This parameterization of theta is
unconventional, but has useful properties when modelling. When theta = 0,
the beta-binomial reverts to the binomial distribution. When theta = 1 and
prob = 0.5, the parameters of the beta distribution become alpha = 1 and
beta = 1, which correspond to a uniform distribution for the beta-binomial
probability parameter.
log_lik_beta_binom( x, size = 1, prob = 0.5, theta = 0, tlower = 0, tupper = Inf, memoize = FALSE )log_lik_beta_binom( x, size = 1, prob = 0.5, theta = 0, tlower = 0, tupper = Inf, memoize = FALSE )
x |
A non-negative whole numeric vector of values. |
size |
A non-negative whole numeric vector of the number of trials. |
prob |
A numeric vector of values between 0 and 1 of the probability of success. |
theta |
A non-negative numeric vector of the dispersion for the mixture models (student, gamma-Poisson and beta-binomial). |
tlower |
A numeric vector of the lower truncation point. |
tupper |
A numeric vector of the upper truncation point. |
memoize |
Whether or not to memoize the function. |
An numeric vector of the corresponding log-likelihoods.
Other log_lik_dist:
log_lik_bern(),
log_lik_beta(),
log_lik_binom(),
log_lik_exp(),
log_lik_gamma(),
log_lik_gamma_pois(),
log_lik_gamma_pois_zi(),
log_lik_lnorm(),
log_lik_neg_binom(),
log_lik_norm(),
log_lik_pois(),
log_lik_pois_zi(),
log_lik_skewnorm(),
log_lik_student(),
log_lik_unif()
log_lik_beta_binom(c(0, 1, 2), 3, 0.5, 0)log_lik_beta_binom(c(0, 1, 2), 3, 0.5, 0)
Binomial Log-Likelihood
log_lik_binom(x, size = 1, prob = 0.5, tlower = 0, tupper = Inf)log_lik_binom(x, size = 1, prob = 0.5, tlower = 0, tupper = Inf)
x |
A non-negative whole numeric vector of values. |
size |
A non-negative whole numeric vector of the number of trials. |
prob |
A numeric vector of values between 0 and 1 of the probability of success. |
tlower |
A numeric vector of the lower truncation point. |
tupper |
A numeric vector of the upper truncation point. |
An numeric vector of the corresponding log-likelihoods.
Other log_lik_dist:
log_lik_bern(),
log_lik_beta(),
log_lik_beta_binom(),
log_lik_exp(),
log_lik_gamma(),
log_lik_gamma_pois(),
log_lik_gamma_pois_zi(),
log_lik_lnorm(),
log_lik_neg_binom(),
log_lik_norm(),
log_lik_pois(),
log_lik_pois_zi(),
log_lik_skewnorm(),
log_lik_student(),
log_lik_unif()
log_lik_binom(c(0, 1, 2), 2, 0.3)log_lik_binom(c(0, 1, 2), 2, 0.3)
The exponential distribution is parameterized in terms of the rate.
log_lik_exp(x, rate = 1, tlower = 0, tupper = Inf)log_lik_exp(x, rate = 1, tlower = 0, tupper = Inf)
x |
A non-negative numeric vector of values. |
rate |
A non-negative numeric vector of rate. |
tlower |
A numeric vector of the lower truncation point. |
tupper |
A numeric vector of the upper truncation point. |
A numeric vector of the corresponding log-likelihoods.
Other log_lik_dist:
log_lik_bern(),
log_lik_beta(),
log_lik_beta_binom(),
log_lik_binom(),
log_lik_gamma(),
log_lik_gamma_pois(),
log_lik_gamma_pois_zi(),
log_lik_lnorm(),
log_lik_neg_binom(),
log_lik_norm(),
log_lik_pois(),
log_lik_pois_zi(),
log_lik_skewnorm(),
log_lik_student(),
log_lik_unif()
log_lik_exp(c(0, 1, 2), 2)log_lik_exp(c(0, 1, 2), 2)
Gamma Log-Likelihood
log_lik_gamma(x, shape = 1, rate = 1, tlower = 0, tupper = Inf)log_lik_gamma(x, shape = 1, rate = 1, tlower = 0, tupper = Inf)
x |
A numeric vector of values. |
shape |
A non-negative numeric vector of shape. |
rate |
A non-negative numeric vector of rate. |
tlower |
A numeric vector of the lower truncation point. |
tupper |
A numeric vector of the upper truncation point. |
An numeric vector of the corresponding log-likelihoods.
Other log_lik_dist:
log_lik_bern(),
log_lik_beta(),
log_lik_beta_binom(),
log_lik_binom(),
log_lik_exp(),
log_lik_gamma_pois(),
log_lik_gamma_pois_zi(),
log_lik_lnorm(),
log_lik_neg_binom(),
log_lik_norm(),
log_lik_pois(),
log_lik_pois_zi(),
log_lik_skewnorm(),
log_lik_student(),
log_lik_unif()
log_lik_gamma(c(0, 1, 2), 1, 2)log_lik_gamma(c(0, 1, 2), 1, 2)
Gamma-Poisson Log-Likelihood
log_lik_gamma_pois(x, lambda = 1, theta = 0, tlower = 0, tupper = Inf)log_lik_gamma_pois(x, lambda = 1, theta = 0, tlower = 0, tupper = Inf)
x |
A non-negative whole numeric vector of values. |
lambda |
A non-negative numeric vector of means. |
theta |
A non-negative numeric vector of the dispersion for the mixture models (student, gamma-Poisson and beta-binomial). |
tlower |
A numeric vector of the lower truncation point. |
tupper |
A numeric vector of the upper truncation point. |
An numeric vector of the corresponding log-likelihoods.
Other log_lik_dist:
log_lik_bern(),
log_lik_beta(),
log_lik_beta_binom(),
log_lik_binom(),
log_lik_exp(),
log_lik_gamma(),
log_lik_gamma_pois_zi(),
log_lik_lnorm(),
log_lik_neg_binom(),
log_lik_norm(),
log_lik_pois(),
log_lik_pois_zi(),
log_lik_skewnorm(),
log_lik_student(),
log_lik_unif()
log_lik_gamma_pois(c(0, 1, 2), 1, 1)log_lik_gamma_pois(c(0, 1, 2), 1, 1)
Zero-Inflated Gamma-Poisson Log-Likelihood
log_lik_gamma_pois_zi( x, lambda = 1, theta = 0, prob = 0, tlower = 0, tupper = Inf )log_lik_gamma_pois_zi( x, lambda = 1, theta = 0, prob = 0, tlower = 0, tupper = Inf )
x |
A non-negative whole numeric vector of values. |
lambda |
A non-negative numeric vector of means. |
theta |
A non-negative numeric vector of the dispersion for the mixture models (student, gamma-Poisson and beta-binomial). |
prob |
A numeric vector of values between 0 and 1 of the probability of success. |
tlower |
A numeric vector of the lower truncation point. |
tupper |
A numeric vector of the upper truncation point. |
An numeric vector of the corresponding log-likelihoods.
Other log_lik_dist:
log_lik_bern(),
log_lik_beta(),
log_lik_beta_binom(),
log_lik_binom(),
log_lik_exp(),
log_lik_gamma(),
log_lik_gamma_pois(),
log_lik_lnorm(),
log_lik_neg_binom(),
log_lik_norm(),
log_lik_pois(),
log_lik_pois_zi(),
log_lik_skewnorm(),
log_lik_student(),
log_lik_unif()
log_lik_gamma_pois_zi(c(1, 3, 4), 3, 1, prob = 0.5)log_lik_gamma_pois_zi(c(1, 3, 4), 3, 1, prob = 0.5)
Log-Normal Log-Likelihood
log_lik_lnorm(x, meanlog = 0, sdlog = 1, tlower = 0, tupper = Inf)log_lik_lnorm(x, meanlog = 0, sdlog = 1, tlower = 0, tupper = Inf)
x |
A numeric vector of values. |
meanlog |
A numeric vector of the means on the log scale. |
sdlog |
A non-negative numeric vector of the standard deviations on the log scale. |
tlower |
A numeric vector of the lower truncation point. |
tupper |
A numeric vector of the upper truncation point. |
An numeric vector of the corresponding log-likelihoods.
Other log_lik_dist:
log_lik_bern(),
log_lik_beta(),
log_lik_beta_binom(),
log_lik_binom(),
log_lik_exp(),
log_lik_gamma(),
log_lik_gamma_pois(),
log_lik_gamma_pois_zi(),
log_lik_neg_binom(),
log_lik_norm(),
log_lik_pois(),
log_lik_pois_zi(),
log_lik_skewnorm(),
log_lik_student(),
log_lik_unif()
log_lik_lnorm(10, 0, 2)log_lik_lnorm(10, 0, 2)
Negative Binomial Log-Likelihood
log_lik_neg_binom(x, lambda = 1, theta = 0, tlower = 0, tupper = Inf)log_lik_neg_binom(x, lambda = 1, theta = 0, tlower = 0, tupper = Inf)
x |
A non-negative whole numeric vector of values. |
lambda |
A non-negative numeric vector of means. |
theta |
A non-negative numeric vector of the dispersion for the mixture models (student, gamma-Poisson and beta-binomial). |
tlower |
A numeric vector of the lower truncation point. |
tupper |
A numeric vector of the upper truncation point. |
An numeric vector of the corresponding log-likelihoods.
Other log_lik_dist:
log_lik_bern(),
log_lik_beta(),
log_lik_beta_binom(),
log_lik_binom(),
log_lik_exp(),
log_lik_gamma(),
log_lik_gamma_pois(),
log_lik_gamma_pois_zi(),
log_lik_lnorm(),
log_lik_norm(),
log_lik_pois(),
log_lik_pois_zi(),
log_lik_skewnorm(),
log_lik_student(),
log_lik_unif()
log_lik_neg_binom(c(0, 1, 2), 2, 1)log_lik_neg_binom(c(0, 1, 2), 2, 1)
Normal Log-Likelihood
log_lik_norm(x, mean = 0, sd = 1, tlower = -Inf, tupper = Inf)log_lik_norm(x, mean = 0, sd = 1, tlower = -Inf, tupper = Inf)
x |
A numeric vector of values. |
mean |
A numeric vector of the means. |
sd |
A non-negative numeric vector of the standard deviations. |
tlower |
A numeric vector of the lower truncation point. |
tupper |
A numeric vector of the upper truncation point. |
An numeric vector of the corresponding log-likelihoods.
Other log_lik_dist:
log_lik_bern(),
log_lik_beta(),
log_lik_beta_binom(),
log_lik_binom(),
log_lik_exp(),
log_lik_gamma(),
log_lik_gamma_pois(),
log_lik_gamma_pois_zi(),
log_lik_lnorm(),
log_lik_neg_binom(),
log_lik_pois(),
log_lik_pois_zi(),
log_lik_skewnorm(),
log_lik_student(),
log_lik_unif()
log_lik_norm(c(-2:2))log_lik_norm(c(-2:2))
Poisson Log-Likelihood
log_lik_pois(x, lambda = 1, tlower = 0, tupper = Inf)log_lik_pois(x, lambda = 1, tlower = 0, tupper = Inf)
x |
A non-negative whole numeric vector of values. |
lambda |
A non-negative numeric vector of means. |
tlower |
A numeric vector of the lower truncation point. |
tupper |
A numeric vector of the upper truncation point. |
An numeric vector of the corresponding log-likelihoods.
Other log_lik_dist:
log_lik_bern(),
log_lik_beta(),
log_lik_beta_binom(),
log_lik_binom(),
log_lik_exp(),
log_lik_gamma(),
log_lik_gamma_pois(),
log_lik_gamma_pois_zi(),
log_lik_lnorm(),
log_lik_neg_binom(),
log_lik_norm(),
log_lik_pois_zi(),
log_lik_skewnorm(),
log_lik_student(),
log_lik_unif()
log_lik_pois(c(1, 3, 4), 3)log_lik_pois(c(1, 3, 4), 3)
Zero-Inflated Poisson Log-Likelihood
log_lik_pois_zi(x, lambda = 1, prob = 0, tlower = 0, tupper = Inf)log_lik_pois_zi(x, lambda = 1, prob = 0, tlower = 0, tupper = Inf)
x |
A non-negative whole numeric vector of values. |
lambda |
A non-negative numeric vector of means. |
prob |
A numeric vector of values between 0 and 1 of the probability of success. |
tlower |
A numeric vector of the lower truncation point. |
tupper |
A numeric vector of the upper truncation point. |
An numeric vector of the corresponding log-likelihoods.
Other log_lik_dist:
log_lik_bern(),
log_lik_beta(),
log_lik_beta_binom(),
log_lik_binom(),
log_lik_exp(),
log_lik_gamma(),
log_lik_gamma_pois(),
log_lik_gamma_pois_zi(),
log_lik_lnorm(),
log_lik_neg_binom(),
log_lik_norm(),
log_lik_pois(),
log_lik_skewnorm(),
log_lik_student(),
log_lik_unif()
log_lik_pois_zi(c(1, 3, 4), 3, prob = 0.5)log_lik_pois_zi(c(1, 3, 4), 3, prob = 0.5)
Skew Normal Log-Likelihood
log_lik_skewnorm(x, mean = 0, sd = 1, shape = 0, tlower = -Inf, tupper = Inf)log_lik_skewnorm(x, mean = 0, sd = 1, shape = 0, tlower = -Inf, tupper = Inf)
x |
A numeric vector of values. |
mean |
A numeric vector of the means. |
sd |
A non-negative numeric vector of the standard deviations. |
shape |
A numeric vector of shape. |
tlower |
A numeric vector of the lower truncation point. |
tupper |
A numeric vector of the upper truncation point. |
An numeric vector of the corresponding log-likelihoods.
Other log_lik_dist:
log_lik_bern(),
log_lik_beta(),
log_lik_beta_binom(),
log_lik_binom(),
log_lik_exp(),
log_lik_gamma(),
log_lik_gamma_pois(),
log_lik_gamma_pois_zi(),
log_lik_lnorm(),
log_lik_neg_binom(),
log_lik_norm(),
log_lik_pois(),
log_lik_pois_zi(),
log_lik_student(),
log_lik_unif()
log_lik_skewnorm(c(-2:2)) log_lik_skewnorm(c(-2:2), shape = -2) log_lik_skewnorm(c(-2:2), shape = 2)log_lik_skewnorm(c(-2:2)) log_lik_skewnorm(c(-2:2), shape = -2) log_lik_skewnorm(c(-2:2), shape = 2)
Student's t Log-Likelihood
log_lik_student(x, mean = 0, sd = 1, theta = 0, tlower = -Inf, tupper = Inf)log_lik_student(x, mean = 0, sd = 1, theta = 0, tlower = -Inf, tupper = Inf)
x |
A numeric vector of values. |
mean |
A numeric vector of the means. |
sd |
A non-negative numeric vector of the standard deviations. |
theta |
A non-negative numeric vector of the dispersion for the mixture models (student, gamma-Poisson and beta-binomial). |
tlower |
A numeric vector of the lower truncation point. |
tupper |
A numeric vector of the upper truncation point. |
An numeric vector of the corresponding log-likelihoods.
Other log_lik_dist:
log_lik_bern(),
log_lik_beta(),
log_lik_beta_binom(),
log_lik_binom(),
log_lik_exp(),
log_lik_gamma(),
log_lik_gamma_pois(),
log_lik_gamma_pois_zi(),
log_lik_lnorm(),
log_lik_neg_binom(),
log_lik_norm(),
log_lik_pois(),
log_lik_pois_zi(),
log_lik_skewnorm(),
log_lik_unif()
log_lik_student(c(1, 3.5, 4), mean = 1, sd = 2, theta = 1 / 3)log_lik_student(c(1, 3.5, 4), mean = 1, sd = 2, theta = 1 / 3)
Uniform Log-Likelihood
log_lik_unif(x, min = 0, max = 1)log_lik_unif(x, min = 0, max = 1)
x |
A numeric vector of values. |
min |
A numeric vector of the minimums. |
max |
A numeric vector of the maximums. |
An numeric vector of the corresponding log-likelihoods.
Other log_lik_dist:
log_lik_bern(),
log_lik_beta(),
log_lik_beta_binom(),
log_lik_binom(),
log_lik_exp(),
log_lik_gamma(),
log_lik_gamma_pois(),
log_lik_gamma_pois_zi(),
log_lik_lnorm(),
log_lik_neg_binom(),
log_lik_norm(),
log_lik_pois(),
log_lik_pois_zi(),
log_lik_skewnorm(),
log_lik_student()
log_lik_unif(c(0, 0.7, 1))log_lik_unif(c(0, 0.7, 1))
Calculates the log odds for probabilities.
log_odds(x)log_odds(x)
x |
A numeric object (vector, matrix or array) of probabilities. |
A numeric object of the the log odds for each probability.
Other odds:
inv_odds(),
log_odds<-(),
log_odds_ratio(),
odds(),
odds<-(),
odds_ratio()
log_odds(c(0, 0.5, 0.9, 1))log_odds(c(0, 0.5, 0.9, 1))
Calculates the log odds ratio for two probabilities.
log_odds_ratio(x, x2)log_odds_ratio(x, x2)
x |
A numeric object (vector, matrix or array) of probabilities. |
x2 |
A second numeric object of probabilities. |
A numeric object of the log odds ratios.
Other odds:
inv_odds(),
log_odds(),
log_odds<-(),
odds(),
odds<-(),
odds_ratio()
log_odds_ratio(0.5, 0.75)log_odds_ratio(0.5, 0.75)
Calculates the log odds ratio for a vector of two probabilities.
log_odds_ratio2(x)log_odds_ratio2(x)
x |
A numeric vector of length 2. |
A number.
Other odds fun2:
odds_ratio2()
log_odds_ratio2(c(0.5, 0.9)) log_odds_ratio2(c(0.9, 0.5))log_odds_ratio2(c(0.5, 0.9)) log_odds_ratio2(c(0.9, 0.5))
Replaces an object with the inverse log odds of value.
log_odds(x) <- valuelog_odds(x) <- value
x |
An existing R object. |
value |
A numeric atomic object. |
Called for the side effect of updating x.
Other odds:
inv_odds(),
log_odds(),
log_odds_ratio(),
odds(),
odds<-(),
odds_ratio()
x <- NULL log_odds(x) <- 0.5 xx <- NULL log_odds(x) <- 0.5 x
Replaces a object with the exponent of value.
log(x) <- valuelog(x) <- value
x |
An object. |
value |
A numeric atomic object. |
A wrapper on exp(value).
Called for the side effect of updating x.
Other translations:
exp10(),
exp2(),
fabs(),
ilog(),
ilog10(),
ilog2(),
ilogit(),
inv_logit(),
invlogit(),
log10<-(),
log2<-(),
logit(),
logit<-(),
phi(),
pow(),
step()
x <- NULL log(x) <- 0.5 xx <- NULL log(x) <- 0.5 x
Replaces a object with the base 10 exponent of value.
log10(x) <- valuelog10(x) <- value
x |
An object. |
value |
A numeric atomic object. |
A wrapper on exp10(value).
Called for the side effect of updating x.
Other translations:
exp10(),
exp2(),
fabs(),
ilog(),
ilog10(),
ilog2(),
ilogit(),
inv_logit(),
invlogit(),
log2<-(),
log<-(),
logit(),
logit<-(),
phi(),
pow(),
step()
x <- NULL log10(x) <- c(0.5, 5) xx <- NULL log10(x) <- c(0.5, 5) x
Replaces a object with the base 2 exponent of value.
log2(x) <- valuelog2(x) <- value
x |
An object. |
value |
A numeric atomic object. |
A wrapper on exp2(value).
Called for the side effect of updating x.
Other translations:
exp10(),
exp2(),
fabs(),
ilog(),
ilog10(),
ilog2(),
ilogit(),
inv_logit(),
invlogit(),
log10<-(),
log<-(),
logit(),
logit<-(),
phi(),
pow(),
step()
x <- NULL log2(x) <- c(0.5, 5) xx <- NULL log2(x) <- c(0.5, 5) x
Logistic transforms a numeric atomic object.
logit(x)logit(x)
x |
A numeric atomic object. |
A wrapper on stats::qlogis().
The logistically transformed numeric atomic object.
Other translations:
exp10(),
exp2(),
fabs(),
ilog(),
ilog10(),
ilog2(),
ilogit(),
inv_logit(),
invlogit(),
log10<-(),
log2<-(),
log<-(),
logit<-(),
phi(),
pow(),
step()
logit(c(0.25, 0.5, 0.75))logit(c(0.25, 0.5, 0.75))
Logistic Transformation
logit(x) <- valuelogit(x) <- value
x |
An existing object. |
value |
A numeric atomic object of the value to inverse logistically transform. |
A wrapper on stats::plogis(value).
Called for the side effect of updating x.
Other translations:
exp10(),
exp2(),
fabs(),
ilog(),
ilog10(),
ilog2(),
ilogit(),
inv_logit(),
invlogit(),
log10<-(),
log2<-(),
log<-(),
logit(),
phi(),
pow(),
step()
x <- 1 logit(x) <- 0.5 xx <- 1 logit(x) <- 0.5 x
Calculates the quantile-based lower credible limit.
lower(x, conf_level = 0.95, na_rm = FALSE)lower(x, conf_level = 0.95, na_rm = FALSE)
x |
A numeric vector of MCMC values. |
conf_level |
A numeric scalar between 0 and 1 specifying the confidence level. |
na_rm |
A flag specifying whether to remove missing values. |
By default it returns the 95% credible limit which corresponds to the 2.5% quantile.
A number.
Other summary:
direction(),
directional_information(),
kurtosis(),
probability_direction(),
pvalue(),
pzeros(),
skewness(),
svalue(),
upper(),
variance(),
xtr_mean(),
xtr_median(),
xtr_sd(),
zeros(),
zscore()
lower(as.numeric(0:100))lower(as.numeric(0:100))
Coerce an R object to a numeric atomic object.
numericise(x, ...) numericize(x, ...) ## S3 method for class 'logical' numericise(x, ...) ## S3 method for class 'integer' numericise(x, ...) ## S3 method for class 'double' numericise(x, ...) ## S3 method for class 'factor' numericise(x, ...) ## S3 method for class 'Date' numericise(x, ...) ## S3 method for class 'POSIXct' numericise(x, ...) ## S3 method for class 'hms' numericise(x, ...) ## S3 method for class 'matrix' numericise(x, ...) ## S3 method for class 'array' numericise(x, ...) ## S3 method for class 'data.frame' numericise(x, ...)numericise(x, ...) numericize(x, ...) ## S3 method for class 'logical' numericise(x, ...) ## S3 method for class 'integer' numericise(x, ...) ## S3 method for class 'double' numericise(x, ...) ## S3 method for class 'factor' numericise(x, ...) ## S3 method for class 'Date' numericise(x, ...) ## S3 method for class 'POSIXct' numericise(x, ...) ## S3 method for class 'hms' numericise(x, ...) ## S3 method for class 'matrix' numericise(x, ...) ## S3 method for class 'array' numericise(x, ...) ## S3 method for class 'data.frame' numericise(x, ...)
x |
An object. |
... |
Other arguments passed to methods. |
numericize() is an alias for numericise.
If you want to implement a method for a class "foo", implement
numericise.foo().
A numeric atomic object.
numericise(logical): Numericise a logical Object
numericise(integer): Numericise an integer Object
numericise(double): Numericise an double Object
numericise(factor): Numericise a factor
numericise(Date): Numericise a Date vector
numericise(POSIXct): Numericise a POSIXct vector
numericise(hms): Numericise a hms vector
numericise(matrix): Numericise a matrix
numericise(array): Numericise an array
numericise(data.frame): Numericise a data.frame
# logical numericise(TRUE) numericise(matrix(c(TRUE, FALSE), nrow = 2)) # integer numericise(2L) # double numericise(c(1, 3)) # factor numericise(factor(c("c", "a"))) # Date numericise(as.Date("1972-01-01")) # POSIXct numericise(as.POSIXct("1972-01-01", tz = "UTC")) # hms numericise(hms::as_hms("00:01:03")) # matrix numericise(matrix(TRUE)) # array numericise(array(TRUE)) # data.frame numericise(data.frame( logical = c(TRUE, FALSE, NA), integer = 1:3, numeric = c(4, 10, NA), factor = as.factor(c("c", "A", "green")) ))# logical numericise(TRUE) numericise(matrix(c(TRUE, FALSE), nrow = 2)) # integer numericise(2L) # double numericise(c(1, 3)) # factor numericise(factor(c("c", "a"))) # Date numericise(as.Date("1972-01-01")) # POSIXct numericise(as.POSIXct("1972-01-01", tz = "UTC")) # hms numericise(hms::as_hms("00:01:03")) # matrix numericise(matrix(TRUE)) # array numericise(array(TRUE)) # data.frame numericise(data.frame( logical = c(TRUE, FALSE, NA), integer = 1:3, numeric = c(4, 10, NA), factor = as.factor(c("c", "A", "green")) ))
Calculates the odds for probabilities.
odds(x)odds(x)
x |
A numeric object (vector, matrix or array) of probabilities. |
A numeric object of the the odds for each probability.
Other odds:
inv_odds(),
log_odds(),
log_odds<-(),
log_odds_ratio(),
odds<-(),
odds_ratio()
odds(c(0, 0.5, 0.9, 1))odds(c(0, 0.5, 0.9, 1))
Calculates the odds ratio for two probabilities.
odds_ratio(x, x2)odds_ratio(x, x2)
x |
A numeric object (vector, matrix or array) of probabilities. |
x2 |
A second numeric object of probabilities. |
A numeric object of the odds ratios.
Other odds:
inv_odds(),
log_odds(),
log_odds<-(),
log_odds_ratio(),
odds(),
odds<-()
odds_ratio(0.5, 0.75)odds_ratio(0.5, 0.75)
Calculates the odds ratio for a vector of two probabilities.
odds_ratio2(x)odds_ratio2(x)
x |
A numeric vector of length 2. |
A number.
Other odds fun2:
log_odds_ratio2()
odds_ratio2(c(0.5, 0.9)) odds_ratio2(c(0.9, 0.5))odds_ratio2(c(0.5, 0.9)) odds_ratio2(c(0.9, 0.5))
Replaces an object with the inverse odds of value.
odds(x) <- valueodds(x) <- value
x |
An existing R object. |
value |
A numeric atomic object. |
Called for the side effect of updating x.
Other odds:
inv_odds(),
log_odds(),
log_odds<-(),
log_odds_ratio(),
odds(),
odds_ratio()
x <- NULL odds(x) <- 0.5 xx <- NULL odds(x) <- 0.5 x
Parameter Pattern
par_pattern()par_pattern()
A string of the regular expression for a parameter name.
par_pattern()par_pattern()
Calculates the probability that a cumulative distribution function
probability is at least that extreme.
pextreme(x)pextreme(x)
x |
A numeric vector of values between 0 and 1. |
A numeric vector of values between 0 and 1.
Other residuals:
sextreme()
pextreme(seq(0, 1, by = 0.1))pextreme(seq(0, 1, by = 0.1))
The standard normal cumulative density function.
phi(x)phi(x)
x |
A numeric atomic object. |
A wrapper on stats::pnorm().
A numeric atomic object.
Other translations:
exp10(),
exp2(),
fabs(),
ilog(),
ilog10(),
ilog2(),
ilogit(),
inv_logit(),
invlogit(),
log10<-(),
log2<-(),
log<-(),
logit(),
logit<-(),
pow(),
step()
phi(0:2)phi(0:2)
R equivalent to the power function.
pow(x, n)pow(x, n)
x |
A numeric atomic object of the base. |
n |
A numeric atomic object of the exponent. |
Wrapper on x^n.
A numeric atomic object of x raised to n.
Other translations:
exp10(),
exp2(),
fabs(),
ilog(),
ilog10(),
ilog2(),
ilogit(),
inv_logit(),
invlogit(),
log10<-(),
log2<-(),
log<-(),
logit(),
logit<-(),
phi(),
step()
pow(10, 2)pow(10, 2)
Bernoulli Cumulative Distribution Function
prob_bern(x, prob = 0.5)prob_bern(x, prob = 0.5)
x |
A numeric vector of quantiles. |
prob |
A numeric vector of values between 0 and 1 of the probability of success. |
An numeric vector of the corresponding probabilities.
Other prob_dist:
prob_beta(),
prob_beta_binom(),
prob_binom(),
prob_exp(),
prob_gamma(),
prob_gamma_pois(),
prob_gamma_pois_zi(),
prob_lnorm(),
prob_neg_binom(),
prob_norm(),
prob_pois(),
prob_pois_zi(),
prob_skewnorm(),
prob_student(),
prob_unif()
prob_bern(c(TRUE, FALSE), 0.7)prob_bern(c(TRUE, FALSE), 0.7)
Beta Cumulative Distribution Function
prob_beta(x, alpha = 1, beta = 1)prob_beta(x, alpha = 1, beta = 1)
x |
A numeric vector of quantiles. |
alpha |
The first shape parameter of the beta distribution. |
beta |
The second shape parameter of the beta distribution. |
An numeric vector of the corresponding probabilities.
Other prob_dist:
prob_bern(),
prob_beta_binom(),
prob_binom(),
prob_exp(),
prob_gamma(),
prob_gamma_pois(),
prob_gamma_pois_zi(),
prob_lnorm(),
prob_neg_binom(),
prob_norm(),
prob_pois(),
prob_pois_zi(),
prob_skewnorm(),
prob_student(),
prob_unif()
prob_beta(c(0, 0.5, 1), 2, 3)prob_beta(c(0, 0.5, 1), 2, 3)
This parameterization of the beta-binomial distribution uses an expected
probability parameter, prob, and a dispersion parameter, theta. The
parameters of the underlying beta mixture are alpha = (2 * prob) / theta
and beta = (2 * (1 - prob)) / theta. This parameterization of theta is
unconventional, but has useful properties when modelling. When theta = 0,
the beta-binomial reverts to the binomial distribution. When theta = 1 and
prob = 0.5, the parameters of the beta distribution become alpha = 1 and
beta = 1, which correspond to a uniform distribution for the beta-binomial
probability parameter.
prob_beta_binom(x, size = 1, prob = 0.5, theta = 0)prob_beta_binom(x, size = 1, prob = 0.5, theta = 0)
x |
A numeric vector of quantiles. |
size |
A non-negative whole numeric vector of the number of trials. |
prob |
A numeric vector of values between 0 and 1 of the probability of success. |
theta |
A non-negative numeric vector of the dispersion for the mixture models (student, gamma-Poisson and beta-binomial). |
An numeric vector of the corresponding probabilities.
Other prob_dist:
prob_bern(),
prob_beta(),
prob_binom(),
prob_exp(),
prob_gamma(),
prob_gamma_pois(),
prob_gamma_pois_zi(),
prob_lnorm(),
prob_neg_binom(),
prob_norm(),
prob_pois(),
prob_pois_zi(),
prob_skewnorm(),
prob_student(),
prob_unif()
prob_beta_binom(c(0, 1, 2), 3, 0.5, 0)prob_beta_binom(c(0, 1, 2), 3, 0.5, 0)
Binomial Cumulative Distribution Function
prob_binom(x, size = 1, prob = 0.5)prob_binom(x, size = 1, prob = 0.5)
x |
A numeric vector of quantiles. |
size |
A non-negative whole numeric vector of the number of trials. |
prob |
A numeric vector of values between 0 and 1 of the probability of success. |
An numeric vector of the corresponding probabilities.
Other prob_dist:
prob_bern(),
prob_beta(),
prob_beta_binom(),
prob_exp(),
prob_gamma(),
prob_gamma_pois(),
prob_gamma_pois_zi(),
prob_lnorm(),
prob_neg_binom(),
prob_norm(),
prob_pois(),
prob_pois_zi(),
prob_skewnorm(),
prob_student(),
prob_unif()
prob_binom(c(0, 1, 2), 2, 0.3)prob_binom(c(0, 1, 2), 2, 0.3)
Exponential Cumulative Distribution Function
prob_exp(x, rate = 1)prob_exp(x, rate = 1)
x |
A numeric vector of quantiles. |
rate |
A non-negative numeric vector of rate. |
An numeric vector of the corresponding probabilities.
Other prob_dist:
prob_bern(),
prob_beta(),
prob_beta_binom(),
prob_binom(),
prob_gamma(),
prob_gamma_pois(),
prob_gamma_pois_zi(),
prob_lnorm(),
prob_neg_binom(),
prob_norm(),
prob_pois(),
prob_pois_zi(),
prob_skewnorm(),
prob_student(),
prob_unif()
prob_exp(c(0, 1, 2), 2)prob_exp(c(0, 1, 2), 2)
Gamma Cumulative Distribution Function
prob_gamma(x, shape = 1, rate = 1)prob_gamma(x, shape = 1, rate = 1)
x |
A numeric vector of quantiles. |
shape |
A non-negative numeric vector of shape. |
rate |
A non-negative numeric vector of rate. |
An numeric vector of the corresponding probabilities.
Other prob_dist:
prob_bern(),
prob_beta(),
prob_beta_binom(),
prob_binom(),
prob_exp(),
prob_gamma_pois(),
prob_gamma_pois_zi(),
prob_lnorm(),
prob_neg_binom(),
prob_norm(),
prob_pois(),
prob_pois_zi(),
prob_skewnorm(),
prob_student(),
prob_unif()
prob_gamma(c(0, 1, 2), 1, 2)prob_gamma(c(0, 1, 2), 1, 2)
Gamma-Poisson Cumulative Distribution Function
prob_gamma_pois(x, lambda = 1, theta = 0)prob_gamma_pois(x, lambda = 1, theta = 0)
x |
A numeric vector of quantiles. |
lambda |
A non-negative numeric vector of means. |
theta |
A non-negative numeric vector of the dispersion for the mixture models (student, gamma-Poisson and beta-binomial). |
An numeric vector of the corresponding probabilities.
Other prob_dist:
prob_bern(),
prob_beta(),
prob_beta_binom(),
prob_binom(),
prob_exp(),
prob_gamma(),
prob_gamma_pois_zi(),
prob_lnorm(),
prob_neg_binom(),
prob_norm(),
prob_pois(),
prob_pois_zi(),
prob_skewnorm(),
prob_student(),
prob_unif()
prob_gamma_pois(c(0, 1, 2), 1, 1)prob_gamma_pois(c(0, 1, 2), 1, 1)
Zero-Inflated Gamma-Poisson Cumulative Distribution Function
prob_gamma_pois_zi(x, lambda = 1, theta = 0, prob = 0)prob_gamma_pois_zi(x, lambda = 1, theta = 0, prob = 0)
x |
A numeric vector of quantiles. |
lambda |
A non-negative numeric vector of means. |
theta |
A non-negative numeric vector of the dispersion for the mixture models (student, gamma-Poisson and beta-binomial). |
prob |
A numeric vector of values between 0 and 1 of the probability of success. |
An numeric vector of the corresponding probabilities.
Other prob_dist:
prob_bern(),
prob_beta(),
prob_beta_binom(),
prob_binom(),
prob_exp(),
prob_gamma(),
prob_gamma_pois(),
prob_lnorm(),
prob_neg_binom(),
prob_norm(),
prob_pois(),
prob_pois_zi(),
prob_skewnorm(),
prob_student(),
prob_unif()
prob_gamma_pois_zi(c(1, 3, 4), 3, 1, prob = 0.5)prob_gamma_pois_zi(c(1, 3, 4), 3, 1, prob = 0.5)
Log-Normal Cumulative Distribution Function
prob_lnorm(x, meanlog = 0, sdlog = 1)prob_lnorm(x, meanlog = 0, sdlog = 1)
x |
A numeric vector of quantiles. |
meanlog |
A numeric vector of the means on the log scale. |
sdlog |
A non-negative numeric vector of the standard deviations on the log scale. |
An numeric vector of the corresponding probabilities.
Other prob_dist:
prob_bern(),
prob_beta(),
prob_beta_binom(),
prob_binom(),
prob_exp(),
prob_gamma(),
prob_gamma_pois(),
prob_gamma_pois_zi(),
prob_neg_binom(),
prob_norm(),
prob_pois(),
prob_pois_zi(),
prob_skewnorm(),
prob_student(),
prob_unif()
prob_lnorm(10, 0, 2)prob_lnorm(10, 0, 2)
Negative Binomial Cumulative Distribution Function
prob_neg_binom(x, lambda = 1, theta = 0)prob_neg_binom(x, lambda = 1, theta = 0)
x |
A numeric vector of quantiles. |
lambda |
A non-negative numeric vector of means. |
theta |
A non-negative numeric vector of the dispersion for the mixture models (student, gamma-Poisson and beta-binomial). |
An numeric vector of the corresponding probabilities.
Other prob_dist:
prob_bern(),
prob_beta(),
prob_beta_binom(),
prob_binom(),
prob_exp(),
prob_gamma(),
prob_gamma_pois(),
prob_gamma_pois_zi(),
prob_lnorm(),
prob_norm(),
prob_pois(),
prob_pois_zi(),
prob_skewnorm(),
prob_student(),
prob_unif()
prob_neg_binom(c(0, 1, 2), 2, 1)prob_neg_binom(c(0, 1, 2), 2, 1)
Normal Cumulative Distribution Function
prob_norm(x, mean = 0, sd = 1)prob_norm(x, mean = 0, sd = 1)
x |
A numeric vector of quantiles. |
mean |
A numeric vector of the means. |
sd |
A non-negative numeric vector of the standard deviations. |
An numeric vector of the corresponding probabilities.
Other prob_dist:
prob_bern(),
prob_beta(),
prob_beta_binom(),
prob_binom(),
prob_exp(),
prob_gamma(),
prob_gamma_pois(),
prob_gamma_pois_zi(),
prob_lnorm(),
prob_neg_binom(),
prob_pois(),
prob_pois_zi(),
prob_skewnorm(),
prob_student(),
prob_unif()
prob_norm(c(-2:2))prob_norm(c(-2:2))
Poisson Cumulative Distribution Function
prob_pois(x, lambda = 1)prob_pois(x, lambda = 1)
x |
A numeric vector of quantiles. |
lambda |
A non-negative numeric vector of means. |
An numeric vector of the corresponding probabilities.
Other prob_dist:
prob_bern(),
prob_beta(),
prob_beta_binom(),
prob_binom(),
prob_exp(),
prob_gamma(),
prob_gamma_pois(),
prob_gamma_pois_zi(),
prob_lnorm(),
prob_neg_binom(),
prob_norm(),
prob_pois_zi(),
prob_skewnorm(),
prob_student(),
prob_unif()
prob_pois(c(1, 3, 4), 3)prob_pois(c(1, 3, 4), 3)
Zero-Inflated Poisson Cumulative Distribution Function
prob_pois_zi(x, lambda = 1, prob = 0)prob_pois_zi(x, lambda = 1, prob = 0)
x |
A numeric vector of quantiles. |
lambda |
A non-negative numeric vector of means. |
prob |
A numeric vector of values between 0 and 1 of the probability of success. |
An numeric vector of the corresponding probabilities.
Other prob_dist:
prob_bern(),
prob_beta(),
prob_beta_binom(),
prob_binom(),
prob_exp(),
prob_gamma(),
prob_gamma_pois(),
prob_gamma_pois_zi(),
prob_lnorm(),
prob_neg_binom(),
prob_norm(),
prob_pois(),
prob_skewnorm(),
prob_student(),
prob_unif()
prob_pois_zi(c(1, 3, 4), 3, prob = 0.5)prob_pois_zi(c(1, 3, 4), 3, prob = 0.5)
Skew Normal Cumulative Distribution Function
prob_skewnorm(x, mean = 0, sd = 1, shape = 0)prob_skewnorm(x, mean = 0, sd = 1, shape = 0)
x |
A numeric vector of quantiles. |
mean |
A numeric vector of the means. |
sd |
A non-negative numeric vector of the standard deviations. |
shape |
A numeric vector of shape. |
An numeric vector of the corresponding probabilities.
Other prob_dist:
prob_bern(),
prob_beta(),
prob_beta_binom(),
prob_binom(),
prob_exp(),
prob_gamma(),
prob_gamma_pois(),
prob_gamma_pois_zi(),
prob_lnorm(),
prob_neg_binom(),
prob_norm(),
prob_pois(),
prob_pois_zi(),
prob_student(),
prob_unif()
prob_skewnorm(c(-2:2)) prob_skewnorm(c(-2:2), shape = -2) prob_skewnorm(c(-2:2), shape = 2)prob_skewnorm(c(-2:2)) prob_skewnorm(c(-2:2), shape = -2) prob_skewnorm(c(-2:2), shape = 2)
Student's t Cumulative Distribution Function
prob_student(x, mean = 0, sd = 1, theta = 0)prob_student(x, mean = 0, sd = 1, theta = 0)
x |
A numeric vector of quantiles. |
mean |
A numeric vector of the means. |
sd |
A non-negative numeric vector of the standard deviations. |
theta |
A non-negative numeric vector of the dispersion for the mixture models (student, gamma-Poisson and beta-binomial). |
An numeric vector of the corresponding probabilities.
Other prob_dist:
prob_bern(),
prob_beta(),
prob_beta_binom(),
prob_binom(),
prob_exp(),
prob_gamma(),
prob_gamma_pois(),
prob_gamma_pois_zi(),
prob_lnorm(),
prob_neg_binom(),
prob_norm(),
prob_pois(),
prob_pois_zi(),
prob_skewnorm(),
prob_unif()
prob_student(c(1, 3.5, 4), mean = 1, sd = 2, theta = 1 / 3)prob_student(c(1, 3.5, 4), mean = 1, sd = 2, theta = 1 / 3)
Uniform Cumulative Distribution Function
prob_unif(x, min = 0, max = 1)prob_unif(x, min = 0, max = 1)
x |
A numeric vector of quantiles. |
min |
A numeric vector of the minimums. |
max |
A numeric vector of the maximums. |
An numeric vector of the corresponding probabilities.
Other prob_dist:
prob_bern(),
prob_beta(),
prob_beta_binom(),
prob_binom(),
prob_exp(),
prob_gamma(),
prob_gamma_pois(),
prob_gamma_pois_zi(),
prob_lnorm(),
prob_neg_binom(),
prob_norm(),
prob_pois(),
prob_pois_zi(),
prob_skewnorm(),
prob_student()
prob_unif(c(0, 0.5, 1))prob_unif(c(0, 0.5, 1))
The probability of direction (PD) is the proportion of the (posterior) distribution above (right) or below (left) a threshold.
probability_direction(x, side = "median", threshold = 0, na_rm = FALSE)probability_direction(x, side = "median", threshold = 0, na_rm = FALSE)
x |
A numeric vector of MCMC values. |
side |
A character vector of length 1 indicating whether to calculate
the directional probability for the left tail ( |
threshold |
A number of the threshold value, which is excluded from the interval for the probability. |
na_rm |
A flag specifying whether to remove missing values. |
By default, the direction is based on the side of the median value, but it
can be specified to measure support for specific hypotheses.
A right-side PD of 0.9 indicates that the interval spanning from the
threshold to infinity has a coverage of 90%.
Can be used as a measure of certainty in the direction of the estimate
(e.g., positive or negative when using a threshold of 0).
NOTE: probability estimates of 0 or 1 are corrected towards 0.5 by adding
or subtracting 1 / (length(x) + 1), where x is a vector of MCMC samples.
Ideally, x should be large enough as to make the correction negligible.
A number between 0 and 1.
If x has NA values but na_rm is FALSE, returns NA_real.
Makowski, D., Ben-Shachar, M.S., Chen, S.H.A., and Lüdecke, D. 2019. Indices of Effect Existence and Significance in the Bayesian Framework. Front. Psychol. 10: 2767. doi:10.3389/fpsyg.2019.02767.
Other summary:
direction(),
directional_information(),
kurtosis(),
lower(),
pvalue(),
pzeros(),
skewness(),
svalue(),
upper(),
variance(),
xtr_mean(),
xtr_median(),
xtr_sd(),
zeros(),
zscore()
x <- rnorm(1e6, qnorm(0.05, lower.tail = TRUE)) probability_direction(x, side = "left") probability_direction(x, side = "right") # = 1 - probability_direction(x, side = "left") probability_direction(c(0, 0, 1), side = "right") # returns P(X >0) = 1/3 instead of P(X >= 0) = 1 probability_direction(c(1, 1), side = "right") # p = 1 - 1/(n+1)x <- rnorm(1e6, qnorm(0.05, lower.tail = TRUE)) probability_direction(x, side = "left") probability_direction(x, side = "right") # = 1 - probability_direction(x, side = "left") probability_direction(c(0, 0, 1), side = "right") # returns P(X >0) = 1/3 instead of P(X >= 0) = 1 probability_direction(c(1, 1), side = "right") # p = 1 - 1/(n+1)
Calculates the proportional change for two sets of numbers.
proportional_change(x, x2)proportional_change(x, x2)
x |
A numeric object (vector, matrix or array) of non-negative numbers. |
x2 |
A second numeric object of non-negative numbers. |
A numeric object of the proportional change.
Other proportional:
proportional_difference()
proportional_change(1, 2) proportional_change(2, 1)proportional_change(1, 2) proportional_change(2, 1)
Calculates the proportional change for a vector of two non-negative numbers.
proportional_change2(x)proportional_change2(x)
x |
A numeric vector of length 2. |
A number.
Other proportional fun2:
proportional_difference2()
proportional_change2(c(1, 2)) proportional_change2(c(2, 1))proportional_change2(c(1, 2)) proportional_change2(c(2, 1))
Calculates the proportional difference for two sets of numbers.
proportional_difference(x, x2)proportional_difference(x, x2)
x |
A numeric object (vector, matrix or array) of non-negative numbers. |
x2 |
A second numeric object of non-negative numbers. |
A numeric object of the proportional change.
Other proportional:
proportional_change()
proportional_difference(1, 2) proportional_difference(2, 1)proportional_difference(1, 2) proportional_difference(2, 1)
Calculates the proportional difference for a vector of two non-negative numbers.
proportional_difference2(x)proportional_difference2(x)
x |
A numeric vector of length 2. |
A number.
Other proportional fun2:
proportional_change2()
proportional_difference2(c(1, 2)) proportional_difference2(c(2, 1))proportional_difference2(c(1, 2)) proportional_difference2(c(2, 1))
A Bayesian p-value (p) is here defined in terms of the quantile-based (1-p) * 100% credible interval (CRI) that just includes a threshold (Kery and Schaub 2011). By default a p-value of 0.05 indicates that the 95% CRI just includes the threshold value.
Note that the function contains the sample-size correction
to avoid p-values of 0. The function can still
return p-values of 1.
To use as a measure of certainty in the direction of the estimate (i.e.,
positive or negative), see probability_direction().
For p-values converted to bits, see svalue().
To convert MCMC objects to information, see directional_information().
pvalue(x, side = "both", threshold = 0, na_rm = FALSE)pvalue(x, side = "both", threshold = 0, na_rm = FALSE)
x |
A numeric vector of MCMC values. |
side |
A character vector of length 1 indicating whether to calculate
p-values for the left tail ( |
threshold |
A number of the threshold value. |
na_rm |
A flag specifying whether to remove missing values. |
A number between 0 and 1.
If x has NA values but na_rm is FALSE, returns NA_real.
Kery, M., and Schaub, M. 2011. Bayesian population analysis using WinBUGS: a hierarchical perspective. Academic Press, Boston. Available from https://www.vogelwarte.ch/en/research/population-biology/book-bpa/.
Other summary:
direction(),
directional_information(),
kurtosis(),
lower(),
probability_direction(),
pzeros(),
skewness(),
svalue(),
upper(),
variance(),
xtr_mean(),
xtr_median(),
xtr_sd(),
zeros(),
zscore()
x <- rnorm(1e6, qnorm(0.05, lower.tail = TRUE)) pvalue(x) # should be 0.05 * 2 pvalue(x, side = "left") # should be 0.95 pvalue(x, side = "right") # should be 0.05x <- rnorm(1e6, qnorm(0.05, lower.tail = TRUE)) pvalue(x) # should be 0.05 * 2 pvalue(x, side = "left") # should be 0.95 pvalue(x, side = "right") # should be 0.05
The proportion of zeros in an numeric object.
pzeros(x, na_rm = FALSE)pzeros(x, na_rm = FALSE)
x |
A numeric object of MCMC values. |
na_rm |
A flag specifying whether to remove missing values. |
A number between 0 and 1.
Other summary:
direction(),
directional_information(),
kurtosis(),
lower(),
probability_direction(),
pvalue(),
skewness(),
svalue(),
upper(),
variance(),
xtr_mean(),
xtr_median(),
xtr_sd(),
zeros(),
zscore()
pzeros(c(0:2))pzeros(c(0:2))
Bernoulli Quantile Function
quant_bern(x, prob = 0.5)quant_bern(x, prob = 0.5)
x |
A numeric vector of probabilities. |
prob |
A numeric vector of values between 0 and 1 of the probability of success. |
An numeric vector of the corresponding quantiles.
Other quant_dist:
quant_beta(),
quant_binom(),
quant_exp(),
quant_gamma(),
quant_gamma_pois(),
quant_gamma_pois_zi(),
quant_lnorm(),
quant_neg_binom(),
quant_norm(),
quant_pois(),
quant_pois_zi(),
quant_skewnorm(),
quant_student(),
quant_unif()
quant_bern(c(0.3, 0.8), 0.7)quant_bern(c(0.3, 0.8), 0.7)
Beta Quantile Function
quant_beta(x, alpha = 1, beta = 1)quant_beta(x, alpha = 1, beta = 1)
x |
A numeric vector of probabilities. |
alpha |
The first shape parameter of the beta distribution. |
beta |
The second shape parameter of the beta distribution. |
An numeric vector of the corresponding quantiles.
Other quant_dist:
quant_bern(),
quant_binom(),
quant_exp(),
quant_gamma(),
quant_gamma_pois(),
quant_gamma_pois_zi(),
quant_lnorm(),
quant_neg_binom(),
quant_norm(),
quant_pois(),
quant_pois_zi(),
quant_skewnorm(),
quant_student(),
quant_unif()
quant_beta(c(0.1, 0.4, 0.6), 2, 3)quant_beta(c(0.1, 0.4, 0.6), 2, 3)
Binomial Quantile Function
quant_binom(x, size = 1, prob = 0.5)quant_binom(x, size = 1, prob = 0.5)
x |
A numeric vector of probabilities. |
size |
A non-negative whole numeric vector of the number of trials. |
prob |
A numeric vector of values between 0 and 1 of the probability of success. |
An numeric vector of the corresponding quantiles.
Other quant_dist:
quant_bern(),
quant_beta(),
quant_exp(),
quant_gamma(),
quant_gamma_pois(),
quant_gamma_pois_zi(),
quant_lnorm(),
quant_neg_binom(),
quant_norm(),
quant_pois(),
quant_pois_zi(),
quant_skewnorm(),
quant_student(),
quant_unif()
quant_binom(c(0.1, 0.4, 0.6), 2, 0.3)quant_binom(c(0.1, 0.4, 0.6), 2, 0.3)
Exponential Quantile Function
quant_exp(x, rate = 1)quant_exp(x, rate = 1)
x |
A numeric vector of probabilities. |
rate |
A non-negative numeric vector of rate. |
An numeric vector of the corresponding quantiles.
Other quant_dist:
quant_bern(),
quant_beta(),
quant_binom(),
quant_gamma(),
quant_gamma_pois(),
quant_gamma_pois_zi(),
quant_lnorm(),
quant_neg_binom(),
quant_norm(),
quant_pois(),
quant_pois_zi(),
quant_skewnorm(),
quant_student(),
quant_unif()
quant_exp(c(0.1, 0.4, 0.6), 2)quant_exp(c(0.1, 0.4, 0.6), 2)
Gamma Quantile Function
quant_gamma(x, shape = 1, rate = 1)quant_gamma(x, shape = 1, rate = 1)
x |
A numeric vector of probabilities. |
shape |
A non-negative numeric vector of shape. |
rate |
A non-negative numeric vector of rate. |
An numeric vector of the corresponding quantiles.
Other quant_dist:
quant_bern(),
quant_beta(),
quant_binom(),
quant_exp(),
quant_gamma_pois(),
quant_gamma_pois_zi(),
quant_lnorm(),
quant_neg_binom(),
quant_norm(),
quant_pois(),
quant_pois_zi(),
quant_skewnorm(),
quant_student(),
quant_unif()
quant_gamma(c(0.1, 0.4, 0.6), 1, 2)quant_gamma(c(0.1, 0.4, 0.6), 1, 2)
Gamma-Poisson Quantile Function
quant_gamma_pois(x, lambda = 1, theta = 0)quant_gamma_pois(x, lambda = 1, theta = 0)
x |
A numeric vector of probabilities. |
lambda |
A non-negative numeric vector of means. |
theta |
A non-negative numeric vector of the dispersion for the mixture models (student, gamma-Poisson and beta-binomial). |
An numeric vector of the corresponding quantiles.
Other quant_dist:
quant_bern(),
quant_beta(),
quant_binom(),
quant_exp(),
quant_gamma(),
quant_gamma_pois_zi(),
quant_lnorm(),
quant_neg_binom(),
quant_norm(),
quant_pois(),
quant_pois_zi(),
quant_skewnorm(),
quant_student(),
quant_unif()
quant_gamma_pois(c(0.1, 0.4, 0.6), 1, 1)quant_gamma_pois(c(0.1, 0.4, 0.6), 1, 1)
Zero-Inflated Gamma-Poisson Quantile Function
quant_gamma_pois_zi(x, lambda = 1, theta = 0, prob = 0)quant_gamma_pois_zi(x, lambda = 1, theta = 0, prob = 0)
x |
A numeric vector of probabilities. |
lambda |
A non-negative numeric vector of means. |
theta |
A non-negative numeric vector of the dispersion for the mixture models (student, gamma-Poisson and beta-binomial). |
prob |
A numeric vector of values between 0 and 1 of the probability of success. |
An numeric vector of the corresponding quantiles.
Other quant_dist:
quant_bern(),
quant_beta(),
quant_binom(),
quant_exp(),
quant_gamma(),
quant_gamma_pois(),
quant_lnorm(),
quant_neg_binom(),
quant_norm(),
quant_pois(),
quant_pois_zi(),
quant_skewnorm(),
quant_student(),
quant_unif()
quant_gamma_pois_zi(c(0.1, 0.4, 0.6), 3, 1, prob = 0.5)quant_gamma_pois_zi(c(0.1, 0.4, 0.6), 3, 1, prob = 0.5)
Log-Normal Quantile Function
quant_lnorm(x, meanlog = 0, sdlog = 1)quant_lnorm(x, meanlog = 0, sdlog = 1)
x |
A numeric vector of probabilities. |
meanlog |
A numeric vector of the means on the log scale. |
sdlog |
A non-negative numeric vector of the standard deviations on the log scale. |
An numeric vector of the corresponding quantiles.
Other quant_dist:
quant_bern(),
quant_beta(),
quant_binom(),
quant_exp(),
quant_gamma(),
quant_gamma_pois(),
quant_gamma_pois_zi(),
quant_neg_binom(),
quant_norm(),
quant_pois(),
quant_pois_zi(),
quant_skewnorm(),
quant_student(),
quant_unif()
quant_lnorm(c(0.1, 0.4, 0.6), 0, 2)quant_lnorm(c(0.1, 0.4, 0.6), 0, 2)
Negative Binomial Quantile Function
quant_neg_binom(x, lambda = 1, theta = 0)quant_neg_binom(x, lambda = 1, theta = 0)
x |
A numeric vector of probabilities. |
lambda |
A non-negative numeric vector of means. |
theta |
A non-negative numeric vector of the dispersion for the mixture models (student, gamma-Poisson and beta-binomial). |
An numeric vector of the corresponding quantiles.
Other quant_dist:
quant_bern(),
quant_beta(),
quant_binom(),
quant_exp(),
quant_gamma(),
quant_gamma_pois(),
quant_gamma_pois_zi(),
quant_lnorm(),
quant_norm(),
quant_pois(),
quant_pois_zi(),
quant_skewnorm(),
quant_student(),
quant_unif()
quant_neg_binom(c(0.1, 0.4, 0.6), 2, 1)quant_neg_binom(c(0.1, 0.4, 0.6), 2, 1)
Normal Quantile Function
quant_norm(x, mean = 0, sd = 1)quant_norm(x, mean = 0, sd = 1)
x |
A numeric vector of probabilities. |
mean |
A numeric vector of the means. |
sd |
A non-negative numeric vector of the standard deviations. |
An numeric vector of the corresponding quantiles.
Other quant_dist:
quant_bern(),
quant_beta(),
quant_binom(),
quant_exp(),
quant_gamma(),
quant_gamma_pois(),
quant_gamma_pois_zi(),
quant_lnorm(),
quant_neg_binom(),
quant_pois(),
quant_pois_zi(),
quant_skewnorm(),
quant_student(),
quant_unif()
quant_norm(c(0.1, 0.4, 0.6))quant_norm(c(0.1, 0.4, 0.6))
Poisson Quantile Function
quant_pois(x, lambda = 1)quant_pois(x, lambda = 1)
x |
A numeric vector of probabilities. |
lambda |
A non-negative numeric vector of means. |
An numeric vector of the corresponding quantiles.
Other quant_dist:
quant_bern(),
quant_beta(),
quant_binom(),
quant_exp(),
quant_gamma(),
quant_gamma_pois(),
quant_gamma_pois_zi(),
quant_lnorm(),
quant_neg_binom(),
quant_norm(),
quant_pois_zi(),
quant_skewnorm(),
quant_student(),
quant_unif()
quant_pois(c(0.1, 0.4, 0.6), 3)quant_pois(c(0.1, 0.4, 0.6), 3)
Zero-Inflated Poisson Quantile Function
quant_pois_zi(x, lambda = 1, prob = 0)quant_pois_zi(x, lambda = 1, prob = 0)
x |
A numeric vector of probabilities. |
lambda |
A non-negative numeric vector of means. |
prob |
A numeric vector of values between 0 and 1 of the probability of success. |
An numeric vector of the corresponding quantiles.
Other quant_dist:
quant_bern(),
quant_beta(),
quant_binom(),
quant_exp(),
quant_gamma(),
quant_gamma_pois(),
quant_gamma_pois_zi(),
quant_lnorm(),
quant_neg_binom(),
quant_norm(),
quant_pois(),
quant_skewnorm(),
quant_student(),
quant_unif()
quant_pois_zi(c(0.1, 0.4, 0.6), 3, prob = 0.5)quant_pois_zi(c(0.1, 0.4, 0.6), 3, prob = 0.5)
Skew Normal Quantile Function
quant_skewnorm(x, mean = 0, sd = 1, shape = 0)quant_skewnorm(x, mean = 0, sd = 1, shape = 0)
x |
A numeric vector of probabilities. |
mean |
A numeric vector of the means. |
sd |
A non-negative numeric vector of the standard deviations. |
shape |
A numeric vector of shape. |
An numeric vector of the corresponding quantiles.
Other quant_dist:
quant_bern(),
quant_beta(),
quant_binom(),
quant_exp(),
quant_gamma(),
quant_gamma_pois(),
quant_gamma_pois_zi(),
quant_lnorm(),
quant_neg_binom(),
quant_norm(),
quant_pois(),
quant_pois_zi(),
quant_student(),
quant_unif()
quant_skewnorm(c(0.1, 0.4, 0.6)) quant_skewnorm(c(0.1, 0.4, 0.6), shape = -2) quant_skewnorm(c(0.1, 0.4, 0.6), shape = 2)quant_skewnorm(c(0.1, 0.4, 0.6)) quant_skewnorm(c(0.1, 0.4, 0.6), shape = -2) quant_skewnorm(c(0.1, 0.4, 0.6), shape = 2)
Student's t Quantile Function
quant_student(x, mean = 0, sd = 1, theta = 0)quant_student(x, mean = 0, sd = 1, theta = 0)
x |
A numeric vector of probabilities. |
mean |
A numeric vector of the means. |
sd |
A non-negative numeric vector of the standard deviations. |
theta |
A non-negative numeric vector of the dispersion for the mixture models (student, gamma-Poisson and beta-binomial). |
An numeric vector of the corresponding quantiles.
Other quant_dist:
quant_bern(),
quant_beta(),
quant_binom(),
quant_exp(),
quant_gamma(),
quant_gamma_pois(),
quant_gamma_pois_zi(),
quant_lnorm(),
quant_neg_binom(),
quant_norm(),
quant_pois(),
quant_pois_zi(),
quant_skewnorm(),
quant_unif()
quant_student(c(0.1, 0.4, 0.6), mean = 1, sd = 2, theta = 1 / 3)quant_student(c(0.1, 0.4, 0.6), mean = 1, sd = 2, theta = 1 / 3)
Uniform Quantile Function
quant_unif(x, min = 0, max = 1)quant_unif(x, min = 0, max = 1)
x |
A numeric vector of probabilities. |
min |
A numeric vector of the minimums. |
max |
A numeric vector of the maximums. |
An numeric vector of the corresponding quantiles.
Other quant_dist:
quant_bern(),
quant_beta(),
quant_binom(),
quant_exp(),
quant_gamma(),
quant_gamma_pois(),
quant_gamma_pois_zi(),
quant_lnorm(),
quant_neg_binom(),
quant_norm(),
quant_pois(),
quant_pois_zi(),
quant_skewnorm(),
quant_student()
quant_unif(c(0.1, 0.4, 0.6))quant_unif(c(0.1, 0.4, 0.6))
Bernoulli Random Samples
ran_bern(n = 1, prob = 0.5)ran_bern(n = 1, prob = 0.5)
n |
A non-negative whole number of the number of random samples to generate. |
prob |
A numeric vector of values between 0 and 1 of the probability of success. |
A numeric vector of the random samples.
Other ran_dist:
ran_beta_binom(),
ran_binom(),
ran_gamma(),
ran_gamma_pois(),
ran_gamma_pois_zi(),
ran_lnorm(),
ran_neg_binom(),
ran_norm(),
ran_pois(),
ran_pois_zi(),
ran_skewnorm(),
ran_student()
ran_bern(10)ran_bern(10)
This parameterization of the beta-binomial distribution uses an expected
probability parameter, prob, and a dispersion parameter, theta. The
parameters of the underlying beta mixture are alpha = (2 * prob) / theta
and beta = (2 * (1 - prob)) / theta. This parameterization of theta is
unconventional, but has useful properties when modelling. When theta = 0,
the beta-binomial reverts to the binomial distribution. When theta = 1 and
prob = 0.5, the parameters of the beta distribution become alpha = 1 and
beta = 1, which correspond to a uniform distribution for the beta-binomial
probability parameter.
ran_beta_binom(n = 1, size = 1, prob = 0.5, theta = 0)ran_beta_binom(n = 1, size = 1, prob = 0.5, theta = 0)
n |
A non-negative whole number of the number of random samples to generate. |
size |
A non-negative whole numeric vector of the number of trials. |
prob |
A numeric vector of values between 0 and 1 of the probability of success. |
theta |
A non-negative numeric vector of the dispersion for the mixture models (student, gamma-Poisson and beta-binomial). |
A numeric vector of the random samples.
Other ran_dist:
ran_bern(),
ran_binom(),
ran_gamma(),
ran_gamma_pois(),
ran_gamma_pois_zi(),
ran_lnorm(),
ran_neg_binom(),
ran_norm(),
ran_pois(),
ran_pois_zi(),
ran_skewnorm(),
ran_student()
ran_beta_binom(10, 1, 0.5, 0)ran_beta_binom(10, 1, 0.5, 0)
Binomial Random Samples
ran_binom(n = 1, size = 1, prob = 0.5)ran_binom(n = 1, size = 1, prob = 0.5)
n |
A non-negative whole number of the number of random samples to generate. |
size |
A non-negative whole numeric vector of the number of trials. |
prob |
A numeric vector of values between 0 and 1 of the probability of success. |
A numeric vector of the random samples.
Other ran_dist:
ran_bern(),
ran_beta_binom(),
ran_gamma(),
ran_gamma_pois(),
ran_gamma_pois_zi(),
ran_lnorm(),
ran_neg_binom(),
ran_norm(),
ran_pois(),
ran_pois_zi(),
ran_skewnorm(),
ran_student()
ran_binom(10)ran_binom(10)
Gamma Random Samples
ran_gamma(n = 1, shape = 1, rate = 1)ran_gamma(n = 1, shape = 1, rate = 1)
n |
A non-negative whole number of the number of random samples to generate. |
shape |
A non-negative numeric vector of shape. |
rate |
A non-negative numeric vector of rate. |
A numeric vector of the random samples.
Other ran_dist:
ran_bern(),
ran_beta_binom(),
ran_binom(),
ran_gamma_pois(),
ran_gamma_pois_zi(),
ran_lnorm(),
ran_neg_binom(),
ran_norm(),
ran_pois(),
ran_pois_zi(),
ran_skewnorm(),
ran_student()
ran_gamma(10)ran_gamma(10)
Gamma-Poisson Random Samples
ran_gamma_pois(n = 1, lambda = 1, theta = 0)ran_gamma_pois(n = 1, lambda = 1, theta = 0)
n |
A non-negative whole number of the number of random samples to generate. |
lambda |
A non-negative numeric vector of means. |
theta |
A non-negative numeric vector of the dispersion for the mixture models (student, gamma-Poisson and beta-binomial). |
A numeric vector of the random samples.
Other ran_dist:
ran_bern(),
ran_beta_binom(),
ran_binom(),
ran_gamma(),
ran_gamma_pois_zi(),
ran_lnorm(),
ran_neg_binom(),
ran_norm(),
ran_pois(),
ran_pois_zi(),
ran_skewnorm(),
ran_student()
ran_gamma_pois(10, theta = 1)ran_gamma_pois(10, theta = 1)
Zero-Inflated Gamma-Poisson Random Samples
ran_gamma_pois_zi(n = 1, lambda = 1, theta = 0, prob = 0)ran_gamma_pois_zi(n = 1, lambda = 1, theta = 0, prob = 0)
n |
A non-negative whole number of the number of random samples to generate. |
lambda |
A non-negative numeric vector of means. |
theta |
A non-negative numeric vector of the dispersion for the mixture models (student, gamma-Poisson and beta-binomial). |
prob |
A numeric vector of values between 0 and 1 of the probability of success. |
A numeric vector of the random samples.
Other ran_dist:
ran_bern(),
ran_beta_binom(),
ran_binom(),
ran_gamma(),
ran_gamma_pois(),
ran_lnorm(),
ran_neg_binom(),
ran_norm(),
ran_pois(),
ran_pois_zi(),
ran_skewnorm(),
ran_student()
ran_gamma_pois_zi(10, lambda = 3, theta = 1, prob = 0.5)ran_gamma_pois_zi(10, lambda = 3, theta = 1, prob = 0.5)
Log-Normal Random Samples
ran_lnorm(n = 1, meanlog = 0, sdlog = 1)ran_lnorm(n = 1, meanlog = 0, sdlog = 1)
n |
A non-negative whole number of the number of random samples to generate. |
meanlog |
A numeric vector of the means on the log scale. |
sdlog |
A non-negative numeric vector of the standard deviations on the log scale. |
A numeric vector of the random samples.
Other ran_dist:
ran_bern(),
ran_beta_binom(),
ran_binom(),
ran_gamma(),
ran_gamma_pois(),
ran_gamma_pois_zi(),
ran_neg_binom(),
ran_norm(),
ran_pois(),
ran_pois_zi(),
ran_skewnorm(),
ran_student()
ran_lnorm(10)ran_lnorm(10)
Identical to Gamma-Poisson Random Samples.
ran_neg_binom(n = 1, lambda = 1, theta = 0)ran_neg_binom(n = 1, lambda = 1, theta = 0)
n |
A non-negative whole number of the number of random samples to generate. |
lambda |
A non-negative numeric vector of means. |
theta |
A non-negative numeric vector of the dispersion for the mixture models (student, gamma-Poisson and beta-binomial). |
A numeric vector of the random samples.
Other ran_dist:
ran_bern(),
ran_beta_binom(),
ran_binom(),
ran_gamma(),
ran_gamma_pois(),
ran_gamma_pois_zi(),
ran_lnorm(),
ran_norm(),
ran_pois(),
ran_pois_zi(),
ran_skewnorm(),
ran_student()
ran_neg_binom(10, theta = 1)ran_neg_binom(10, theta = 1)
Normal Random Samples
ran_norm(n = 1, mean = 0, sd = 1)ran_norm(n = 1, mean = 0, sd = 1)
n |
A non-negative whole number of the number of random samples to generate. |
mean |
A numeric vector of the means. |
sd |
A non-negative numeric vector of the standard deviations. |
A numeric vector of the random samples.
Other ran_dist:
ran_bern(),
ran_beta_binom(),
ran_binom(),
ran_gamma(),
ran_gamma_pois(),
ran_gamma_pois_zi(),
ran_lnorm(),
ran_neg_binom(),
ran_pois(),
ran_pois_zi(),
ran_skewnorm(),
ran_student()
ran_norm(10)ran_norm(10)
Poisson Random Samples
ran_pois(n = 1, lambda = 1)ran_pois(n = 1, lambda = 1)
n |
A non-negative whole number of the number of random samples to generate. |
lambda |
A non-negative numeric vector of means. |
A numeric vector of the random samples.
Other ran_dist:
ran_bern(),
ran_beta_binom(),
ran_binom(),
ran_gamma(),
ran_gamma_pois(),
ran_gamma_pois_zi(),
ran_lnorm(),
ran_neg_binom(),
ran_norm(),
ran_pois_zi(),
ran_skewnorm(),
ran_student()
ran_pois(10)ran_pois(10)
Zero-Inflated Poisson Random Samples
ran_pois_zi(n = 1, lambda = 1, prob = 0)ran_pois_zi(n = 1, lambda = 1, prob = 0)
n |
A non-negative whole number of the number of random samples to generate. |
lambda |
A non-negative numeric vector of means. |
prob |
A numeric vector of values between 0 and 1 of the probability of success. |
A numeric vector of the random samples.
Other ran_dist:
ran_bern(),
ran_beta_binom(),
ran_binom(),
ran_gamma(),
ran_gamma_pois(),
ran_gamma_pois_zi(),
ran_lnorm(),
ran_neg_binom(),
ran_norm(),
ran_pois(),
ran_skewnorm(),
ran_student()
ran_pois_zi(10, prob = 0.5)ran_pois_zi(10, prob = 0.5)
Skew Normal Random Samples
ran_skewnorm(n = 1, mean = 0, sd = 1, shape = 0)ran_skewnorm(n = 1, mean = 0, sd = 1, shape = 0)
n |
A non-negative whole number of the number of random samples to generate. |
mean |
A numeric vector of the means. |
sd |
A non-negative numeric vector of the standard deviations. |
shape |
A numeric vector of shape. |
A numeric vector of the random samples.
Other ran_dist:
ran_bern(),
ran_beta_binom(),
ran_binom(),
ran_gamma(),
ran_gamma_pois(),
ran_gamma_pois_zi(),
ran_lnorm(),
ran_neg_binom(),
ran_norm(),
ran_pois(),
ran_pois_zi(),
ran_student()
ran_skewnorm(10, shape = -1) ran_skewnorm(10, shape = 0) ran_skewnorm(10, shape = 1)ran_skewnorm(10, shape = -1) ran_skewnorm(10, shape = 0) ran_skewnorm(10, shape = 1)
Student's t Random Samples
ran_student(n = 1, mean = 0, sd = 1, theta = 0)ran_student(n = 1, mean = 0, sd = 1, theta = 0)
n |
A non-negative whole number of the number of random samples to generate. |
mean |
A numeric vector of the means. |
sd |
A non-negative numeric vector of the standard deviations. |
theta |
A non-negative numeric vector of the dispersion for the mixture models (student, gamma-Poisson and beta-binomial). |
A numeric vector of the random samples.
Other ran_dist:
ran_bern(),
ran_beta_binom(),
ran_binom(),
ran_gamma(),
ran_gamma_pois(),
ran_gamma_pois_zi(),
ran_lnorm(),
ran_neg_binom(),
ran_norm(),
ran_pois(),
ran_pois_zi(),
ran_skewnorm()
ran_student(10, theta = 1 / 2)ran_student(10, theta = 1 / 2)
Bernoulli Residuals
res_bern(x, prob = 0.5, type = "dev", simulate = FALSE)res_bern(x, prob = 0.5, type = "dev", simulate = FALSE)
x |
A vector of 0s and 1s. |
prob |
A numeric vector of values between 0 and 1 of the probability of success. |
type |
A string of the residual type. 'raw' for raw residuals 'dev' for deviance residuals and 'data' for the data. |
simulate |
A flag specifying whether to simulate residuals. |
An numeric vector of the corresponding residuals.
Other res_dist:
res_beta_binom(),
res_binom(),
res_gamma(),
res_gamma_pois(),
res_gamma_pois_zi(),
res_lnorm(),
res_neg_binom(),
res_norm(),
res_pois(),
res_pois_zi(),
res_skewnorm(),
res_student()
res_bern(c(TRUE, FALSE), 0.7)res_bern(c(TRUE, FALSE), 0.7)
This parameterization of the beta-binomial distribution uses an expected
probability parameter, prob, and a dispersion parameter, theta. The
parameters of the underlying beta mixture are alpha = (2 * prob) / theta
and beta = (2 * (1 - prob)) / theta. This parameterization of theta is
unconventional, but has useful properties when modelling. When theta = 0,
the beta-binomial reverts to the binomial distribution. When theta = 1 and
prob = 0.5, the parameters of the beta distribution become alpha = 1 and
beta = 1, which correspond to a uniform distribution for the beta-binomial
probability parameter.
res_beta_binom( x, size = 1, prob = 0.5, theta = 0, type = "dev", simulate = FALSE )res_beta_binom( x, size = 1, prob = 0.5, theta = 0, type = "dev", simulate = FALSE )
x |
A non-negative whole numeric vector of values. |
size |
A non-negative whole numeric vector of the number of trials. |
prob |
A numeric vector of values between 0 and 1 of the probability of success. |
theta |
A non-negative numeric vector of the dispersion for the mixture models (student, gamma-Poisson and beta-binomial). |
type |
A string of the residual type. 'raw' for raw residuals 'dev' for deviance residuals and 'data' for the data. |
simulate |
A flag specifying whether to simulate residuals. |
An numeric vector of the corresponding residuals.
Other res_dist:
res_bern(),
res_binom(),
res_gamma(),
res_gamma_pois(),
res_gamma_pois_zi(),
res_lnorm(),
res_neg_binom(),
res_norm(),
res_pois(),
res_pois_zi(),
res_skewnorm(),
res_student()
res_beta_binom(c(0, 1, 2), 4, 0.5, 0.1)res_beta_binom(c(0, 1, 2), 4, 0.5, 0.1)
Binomial Residuals
res_binom(x, size = 1, prob = 0.5, type = "dev", simulate = FALSE)res_binom(x, size = 1, prob = 0.5, type = "dev", simulate = FALSE)
x |
A non-negative whole numeric vector of values. |
size |
A non-negative whole numeric vector of the number of trials. |
prob |
A numeric vector of values between 0 and 1 of the probability of success. |
type |
A string of the residual type. 'raw' for raw residuals 'dev' for deviance residuals and 'data' for the data. |
simulate |
A flag specifying whether to simulate residuals. |
An numeric vector of the corresponding residuals.
Other res_dist:
res_bern(),
res_beta_binom(),
res_gamma(),
res_gamma_pois(),
res_gamma_pois_zi(),
res_lnorm(),
res_neg_binom(),
res_norm(),
res_pois(),
res_pois_zi(),
res_skewnorm(),
res_student()
res_binom(c(0, 1, 2), 2, 0.3)res_binom(c(0, 1, 2), 2, 0.3)
Gamma Residuals
res_gamma(x, shape = 1, rate = 1, type = "dev", simulate = FALSE)res_gamma(x, shape = 1, rate = 1, type = "dev", simulate = FALSE)
x |
A numeric vector of values. |
shape |
A non-negative numeric vector of shape. |
rate |
A non-negative numeric vector of rate. |
type |
A string of the residual type. 'raw' for raw residuals 'dev' for deviance residuals and 'data' for the data. |
simulate |
A flag specifying whether to simulate residuals. |
An numeric vector of the corresponding residuals.
Other res_dist:
res_bern(),
res_beta_binom(),
res_binom(),
res_gamma_pois(),
res_gamma_pois_zi(),
res_lnorm(),
res_neg_binom(),
res_norm(),
res_pois(),
res_pois_zi(),
res_skewnorm(),
res_student()
res_gamma(c(0, 1, 2), 1, 2)res_gamma(c(0, 1, 2), 1, 2)
Gamma-Poisson Residuals
res_gamma_pois(x, lambda = 1, theta = 0, type = "dev", simulate = FALSE)res_gamma_pois(x, lambda = 1, theta = 0, type = "dev", simulate = FALSE)
x |
A non-negative whole numeric vector of values. |
lambda |
A non-negative numeric vector of means. |
theta |
A non-negative numeric vector of the dispersion for the mixture models (student, gamma-Poisson and beta-binomial). |
type |
A string of the residual type. 'raw' for raw residuals 'dev' for deviance residuals and 'data' for the data. |
simulate |
A flag specifying whether to simulate residuals. |
An numeric vector of the corresponding residuals.
Other res_dist:
res_bern(),
res_beta_binom(),
res_binom(),
res_gamma(),
res_gamma_pois_zi(),
res_lnorm(),
res_neg_binom(),
res_norm(),
res_pois(),
res_pois_zi(),
res_skewnorm(),
res_student()
res_gamma_pois(c(0, 1, 2), 1, 1)res_gamma_pois(c(0, 1, 2), 1, 1)
Zero-Inflated Gamma-Poisson Residuals
res_gamma_pois_zi( x, lambda = 1, theta = 0, prob = 0, type = "dev", simulate = FALSE )res_gamma_pois_zi( x, lambda = 1, theta = 0, prob = 0, type = "dev", simulate = FALSE )
x |
A non-negative whole numeric vector of values. |
lambda |
A non-negative numeric vector of means. |
theta |
A non-negative numeric vector of the dispersion for the mixture models (student, gamma-Poisson and beta-binomial). |
prob |
A numeric vector of values between 0 and 1 of the probability of zero-inflation. |
type |
A string of the residual type. 'raw' for raw residuals 'dev' for deviance residuals and 'data' for the data. |
simulate |
A flag specifying whether to simulate residuals. |
An numeric vector of the corresponding residuals.
Other res_dist:
res_bern(),
res_beta_binom(),
res_binom(),
res_gamma(),
res_gamma_pois(),
res_lnorm(),
res_neg_binom(),
res_norm(),
res_pois(),
res_pois_zi(),
res_skewnorm(),
res_student()
res_gamma_pois_zi(c(0, 1, 2), 1, 1, 0.5)res_gamma_pois_zi(c(0, 1, 2), 1, 1, 0.5)
Log-Normal Residuals
res_lnorm(x, meanlog = 0, sdlog = 1, type = "dev", simulate = FALSE)res_lnorm(x, meanlog = 0, sdlog = 1, type = "dev", simulate = FALSE)
x |
A numeric vector of values. |
meanlog |
A numeric vector of the means on the log scale. |
sdlog |
A non-negative numeric vector of the standard deviations on the log scale. |
type |
A string of the residual type. 'raw' for raw residuals 'dev' for deviance residuals and 'data' for the data. |
simulate |
A flag specifying whether to simulate residuals. |
An numeric vector of the corresponding residuals.
Other res_dist:
res_bern(),
res_beta_binom(),
res_binom(),
res_gamma(),
res_gamma_pois(),
res_gamma_pois_zi(),
res_neg_binom(),
res_norm(),
res_pois(),
res_pois_zi(),
res_skewnorm(),
res_student()
res_lnorm(10)res_lnorm(10)
Negative Binomial Residuals
res_neg_binom(x, lambda = 1, theta = 0, type = "dev", simulate = FALSE)res_neg_binom(x, lambda = 1, theta = 0, type = "dev", simulate = FALSE)
x |
A non-negative whole numeric vector of values. |
lambda |
A non-negative numeric vector of means. |
theta |
A non-negative numeric vector of the dispersion for the mixture models (student, gamma-Poisson and beta-binomial). |
type |
A string of the residual type. 'raw' for raw residuals 'dev' for deviance residuals and 'data' for the data. |
simulate |
A flag specifying whether to simulate residuals. |
An numeric vector of the corresponding residuals.
Other res_dist:
res_bern(),
res_beta_binom(),
res_binom(),
res_gamma(),
res_gamma_pois(),
res_gamma_pois_zi(),
res_lnorm(),
res_norm(),
res_pois(),
res_pois_zi(),
res_skewnorm(),
res_student()
res_neg_binom(c(0, 1, 5), 2, 3)res_neg_binom(c(0, 1, 5), 2, 3)
Normal Residuals
res_norm(x, mean = 0, sd = 1, type = "dev", simulate = FALSE)res_norm(x, mean = 0, sd = 1, type = "dev", simulate = FALSE)
x |
A numeric vector of values. |
mean |
A numeric vector of the means. |
sd |
A non-negative numeric vector of the standard deviations. |
type |
A string of the residual type. 'raw' for raw residuals 'dev' for deviance residuals and 'data' for the data. |
simulate |
A flag specifying whether to simulate residuals. |
An numeric vector of the corresponding residuals.
Other res_dist:
res_bern(),
res_beta_binom(),
res_binom(),
res_gamma(),
res_gamma_pois(),
res_gamma_pois_zi(),
res_lnorm(),
res_neg_binom(),
res_pois(),
res_pois_zi(),
res_skewnorm(),
res_student()
res_norm(c(-2:2))res_norm(c(-2:2))
Poisson Residuals
res_pois(x, lambda = 1, type = "dev", simulate = FALSE)res_pois(x, lambda = 1, type = "dev", simulate = FALSE)
x |
A non-negative whole numeric vector of values. |
lambda |
A non-negative numeric vector of means. |
type |
A string of the residual type. 'raw' for raw residuals 'dev' for deviance residuals and 'data' for the data. |
simulate |
A flag specifying whether to simulate residuals. |
An numeric vector of the corresponding residuals.
Other res_dist:
res_bern(),
res_beta_binom(),
res_binom(),
res_gamma(),
res_gamma_pois(),
res_gamma_pois_zi(),
res_lnorm(),
res_neg_binom(),
res_norm(),
res_pois_zi(),
res_skewnorm(),
res_student()
res_pois(c(1, 3, 4), 3)res_pois(c(1, 3, 4), 3)
Zero-Inflated Poisson Residuals
res_pois_zi(x, lambda = 1, prob = 0, type = "dev", simulate = FALSE)res_pois_zi(x, lambda = 1, prob = 0, type = "dev", simulate = FALSE)
x |
A non-negative whole numeric vector of values. |
lambda |
A non-negative numeric vector of means. |
prob |
A numeric vector of values between 0 and 1 of the probability of zero-inflation. |
type |
A string of the residual type. 'raw' for raw residuals 'dev' for deviance residuals and 'data' for the data. |
simulate |
A flag specifying whether to simulate residuals. |
An numeric vector of the corresponding residuals.
Other res_dist:
res_bern(),
res_beta_binom(),
res_binom(),
res_gamma(),
res_gamma_pois(),
res_gamma_pois_zi(),
res_lnorm(),
res_neg_binom(),
res_norm(),
res_pois(),
res_skewnorm(),
res_student()
res_pois_zi(c(1, 3, 4), 6, 0.5, type = "raw")res_pois_zi(c(1, 3, 4), 6, 0.5, type = "raw")
Skew Normal Residuals
res_skewnorm(x, mean = 0, sd = 1, shape = 0, type = "dev", simulate = FALSE)res_skewnorm(x, mean = 0, sd = 1, shape = 0, type = "dev", simulate = FALSE)
x |
A numeric vector of values. |
mean |
A numeric vector of the means. |
sd |
A non-negative numeric vector of the standard deviations. |
shape |
A numeric vector of shape. |
type |
A string of the residual type. 'raw' for raw residuals 'dev' for deviance residuals and 'data' for the data. |
simulate |
A flag specifying whether to simulate residuals. |
An numeric vector of the corresponding residuals.
Other res_dist:
res_bern(),
res_beta_binom(),
res_binom(),
res_gamma(),
res_gamma_pois(),
res_gamma_pois_zi(),
res_lnorm(),
res_neg_binom(),
res_norm(),
res_pois(),
res_pois_zi(),
res_student()
res_skewnorm(c(-2:2))res_skewnorm(c(-2:2))
Student's t Residuals
res_student(x, mean = 0, sd = 1, theta = 0, type = "dev", simulate = FALSE)res_student(x, mean = 0, sd = 1, theta = 0, type = "dev", simulate = FALSE)
x |
A non-negative whole numeric vector of values. |
mean |
A numeric vector of the means. |
sd |
A non-negative numeric vector of the standard deviations. |
theta |
A non-negative numeric vector of the dispersion for the mixture models (student, gamma-Poisson and beta-binomial). |
type |
A string of the residual type. 'raw' for raw residuals 'dev' for deviance residuals and 'data' for the data. |
simulate |
A flag specifying whether to simulate residuals. |
An numeric vector of the corresponding residuals.
Other res_dist:
res_bern(),
res_beta_binom(),
res_binom(),
res_gamma(),
res_gamma_pois(),
res_gamma_pois_zi(),
res_lnorm(),
res_neg_binom(),
res_norm(),
res_pois(),
res_pois_zi(),
res_skewnorm()
res_student(c(1, 3.5, 4), mean = 6, sd = 0.5, theta = 1 / 3, type = "raw")res_student(c(1, 3.5, 4), mean = 6, sd = 0.5, theta = 1 / 3, type = "raw")
Expands (sd_mult > 1) or reduces (sd_mult < 1) the standard deviation
of the Beta distribution. The Beta distribution has a maximum variance of
mean(x) * (1 - mean(x), where mean(x) = alpha / (alpha + beta). If the
inputs produce a desired variance that is greater than the maximum possible
variance, or provides alpha and/or beta parameters that are < 1 and thus
push more probability weight towards extreme probability values, this
function returns alpha = 1 and beta = 1 (the uniform distribution).
sens_beta(alpha, beta, sd_mult = 2)sens_beta(alpha, beta, sd_mult = 2)
alpha |
The first shape parameter of the beta distribution. |
beta |
The second shape parameter of the beta distribution. |
sd_mult |
A non-negative multiplier on the standard deviation of the distribution. |
A named list of the adjusted distribution's parameters.
Other sens_dist:
sens_exp(),
sens_gamma(),
sens_gamma_pois(),
sens_gamma_pois_zi(),
sens_lnorm(),
sens_neg_binom(),
sens_norm(),
sens_pois(),
sens_skewnorm(),
sens_student()
sens_beta(10, 10, 2) sens_beta(10, 10, 0.8)sens_beta(10, 10, 2) sens_beta(10, 10, 0.8)
Expands (sd_mult > 1) or reduces (sd_mult < 1) the standard deviation
of the exponential distribution. Due to the parameterization of this
distribution, adjusting the standard deviation necessarily changes the mean
value.
sens_exp(rate, sd_mult = 2)sens_exp(rate, sd_mult = 2)
rate |
A non-negative numeric vector of rate. |
sd_mult |
A non-negative multiplier on the standard deviation of the distribution. |
A named list of the adjusted distribution's parameters.
Other sens_dist:
sens_beta(),
sens_gamma(),
sens_gamma_pois(),
sens_gamma_pois_zi(),
sens_lnorm(),
sens_neg_binom(),
sens_norm(),
sens_pois(),
sens_skewnorm(),
sens_student()
sens_exp(10, 2) sens_exp(10, 0.8)sens_exp(10, 2) sens_exp(10, 0.8)
Expands (sd_mult > 1) or reduces (sd_mult < 1) the standard deviation
of the Gamma distribution.
sens_gamma(shape, rate, sd_mult = 2)sens_gamma(shape, rate, sd_mult = 2)
shape |
A non-negative numeric vector of shape. |
rate |
A non-negative numeric vector of rate. |
sd_mult |
A non-negative multiplier on the standard deviation of the distribution. |
A named list of the adjusted distribution's parameters.
Other sens_dist:
sens_beta(),
sens_exp(),
sens_gamma_pois(),
sens_gamma_pois_zi(),
sens_lnorm(),
sens_neg_binom(),
sens_norm(),
sens_pois(),
sens_skewnorm(),
sens_student()
sens_gamma(10, 2, 2) sens_gamma(10, 2, 0.2)sens_gamma(10, 2, 2) sens_gamma(10, 2, 0.2)
Expands (sd_mult > 1) the standard deviation of the Negative Binomial
distribution. This function does not currently have the option to reduce the
standard deviation.
sens_gamma_pois(lambda, theta, sd_mult = 2)sens_gamma_pois(lambda, theta, sd_mult = 2)
lambda |
A non-negative numeric vector of means. |
theta |
A non-negative numeric vector of the dispersion for the mixture models (student, gamma-Poisson and beta-binomial). |
sd_mult |
A non-negative multiplier on the standard deviation of the distribution. |
A named list of the adjusted distribution's parameters.
Other sens_dist:
sens_beta(),
sens_exp(),
sens_gamma(),
sens_gamma_pois_zi(),
sens_lnorm(),
sens_neg_binom(),
sens_norm(),
sens_pois(),
sens_skewnorm(),
sens_student()
sens_gamma_pois(10, 0.1, 2)sens_gamma_pois(10, 0.1, 2)
Expands (sd_mult > 1) or reduces (sd_mult < 1) the standard deviation
of the Zero-Inflated Gamma-Poisson distribution.
sens_gamma_pois_zi(lambda, theta, prob, sd_mult = 2)sens_gamma_pois_zi(lambda, theta, prob, sd_mult = 2)
lambda |
A non-negative numeric vector of means. |
theta |
A non-negative numeric vector of the dispersion for the mixture models (student, gamma-Poisson and beta-binomial). |
prob |
A numeric vector of values between 0 and 1 of the probability of success. |
sd_mult |
A non-negative multiplier on the standard deviation of the distribution. |
A named list of the adjusted distribution's parameters.
Other sens_dist:
sens_beta(),
sens_exp(),
sens_gamma(),
sens_gamma_pois(),
sens_lnorm(),
sens_neg_binom(),
sens_norm(),
sens_pois(),
sens_skewnorm(),
sens_student()
sens_gamma_pois_zi(10, 0.1, 0.3, 2)sens_gamma_pois_zi(10, 0.1, 0.3, 2)
Expands (sd_mult > 1) or reduces (sd_mult < 1) the standard deviation
of the Log-Normal distribution. With high values of sdlog (i.e., > 9),
and sd_mult > 1, the mean of the adjusted distribution can be expected to
have a mean value that is very different from the original mean, however,
the proportional difference in these values should not be very different.
sens_lnorm(meanlog, sdlog, sd_mult = 2)sens_lnorm(meanlog, sdlog, sd_mult = 2)
meanlog |
A numeric vector of the means on the log scale. |
sdlog |
A non-negative numeric vector of the standard deviations on the log scale. |
sd_mult |
A non-negative multiplier on the standard deviation of the distribution. |
A named list of the adjusted distribution's parameters.
Other sens_dist:
sens_beta(),
sens_exp(),
sens_gamma(),
sens_gamma_pois(),
sens_gamma_pois_zi(),
sens_neg_binom(),
sens_norm(),
sens_pois(),
sens_skewnorm(),
sens_student()
sens_lnorm(0, 1, 2) sens_lnorm(0, 1, 0.8)sens_lnorm(0, 1, 2) sens_lnorm(0, 1, 0.8)
Expands (sd_mult > 1) the standard deviation of the Negative Binomial
distribution. This function does not currently have the option to reduce the
standard deviation.
sens_neg_binom(lambda, theta, sd_mult = 2)sens_neg_binom(lambda, theta, sd_mult = 2)
lambda |
A non-negative numeric vector of means. |
theta |
A non-negative numeric vector of the dispersion for the mixture models (student, gamma-Poisson and beta-binomial). |
sd_mult |
A non-negative multiplier on the standard deviation of the distribution. |
A named list of the adjusted distribution's parameters.
Other sens_dist:
sens_beta(),
sens_exp(),
sens_gamma(),
sens_gamma_pois(),
sens_gamma_pois_zi(),
sens_lnorm(),
sens_norm(),
sens_pois(),
sens_skewnorm(),
sens_student()
sens_neg_binom(10, 0.1, 2)sens_neg_binom(10, 0.1, 2)
Expands (sd_mult > 1) or reduces (sd_mult < 1) the standard deviation
of the Normal distribution without changing the mean.
sens_norm(mean, sd, sd_mult = 2)sens_norm(mean, sd, sd_mult = 2)
mean |
A numeric vector of the means. |
sd |
A non-negative numeric vector of the standard deviations. |
sd_mult |
A non-negative multiplier on the standard deviation of the distribution. |
A named list of the adjusted distribution's parameters.
Other sens_dist:
sens_beta(),
sens_exp(),
sens_gamma(),
sens_gamma_pois(),
sens_gamma_pois_zi(),
sens_lnorm(),
sens_neg_binom(),
sens_pois(),
sens_skewnorm(),
sens_student()
sens_norm(10, 3, 2) sens_norm(10, 3, 0.8)sens_norm(10, 3, 2) sens_norm(10, 3, 0.8)
Expands (sd_mult > 1) or reduces (sd_mult < 1) the standard deviation
of the Poisson distribution. Due to the parameterization of this
distribution, adjusting the standard deviation necessarily changes the mean
value.
sens_pois(lambda, sd_mult = 2)sens_pois(lambda, sd_mult = 2)
lambda |
A non-negative numeric vector of means. |
sd_mult |
A non-negative multiplier on the standard deviation of the distribution. |
A named list of the adjusted distribution's parameters.
Other sens_dist:
sens_beta(),
sens_exp(),
sens_gamma(),
sens_gamma_pois(),
sens_gamma_pois_zi(),
sens_lnorm(),
sens_neg_binom(),
sens_norm(),
sens_skewnorm(),
sens_student()
sens_pois(10, 2) sens_pois(10, 0.8)sens_pois(10, 2) sens_pois(10, 0.8)
Expands (sd_mult > 1) or reduces (sd_mult < 1) the standard deviation
of the Skew Normal distribution without changing the mean.
sens_skewnorm(mean, sd, shape, sd_mult = 2)sens_skewnorm(mean, sd, shape, sd_mult = 2)
mean |
A numeric vector of the means. |
sd |
A non-negative numeric vector of the standard deviations. |
shape |
A non-negative numeric vector of shape. |
sd_mult |
A non-negative multiplier on the standard deviation of the distribution. |
A named list of the adjusted distribution's parameters.
Other sens_dist:
sens_beta(),
sens_exp(),
sens_gamma(),
sens_gamma_pois(),
sens_gamma_pois_zi(),
sens_lnorm(),
sens_neg_binom(),
sens_norm(),
sens_pois(),
sens_student()
sens_skewnorm(10, 3, -1, 2) sens_skewnorm(10, 3, 3, 0.8)sens_skewnorm(10, 3, -1, 2) sens_skewnorm(10, 3, 3, 0.8)
Expands (sd_mult > 1) or reduces (sd_mult < 1) the standard deviation
of the Student's t distribution. Because the variance of this distribution
is not defined for every degree of freedom, the adjustment to the standard
deviation is approximate, and the mean of the adjusted distribution can
be expected to have shifted.
sens_student(mean, sd, theta, sd_mult = 2)sens_student(mean, sd, theta, sd_mult = 2)
mean |
A numeric vector of the means. |
sd |
A non-negative numeric vector of the standard deviations. |
theta |
A non-negative numeric vector of the dispersion for the mixture models (student, gamma-Poisson and beta-binomial). |
sd_mult |
A non-negative multiplier on the standard deviation of the distribution. |
A named list of the adjusted distribution's parameters.
Other sens_dist:
sens_beta(),
sens_exp(),
sens_gamma(),
sens_gamma_pois(),
sens_gamma_pois_zi(),
sens_lnorm(),
sens_neg_binom(),
sens_norm(),
sens_pois(),
sens_skewnorm()
sens_student(10, 3, 0.1, 2) sens_student(10, 3, 0.1, 0.8)sens_student(10, 3, 0.1, 2) sens_student(10, 3, 0.1, 0.8)
Calculates the surprisal (in bits) that a cumulative distribution function
probability is at least that extreme.
sextreme(x, directional = FALSE)sextreme(x, directional = FALSE)
x |
A numeric vector of values between 0 and 1. |
directional |
A flag specifying whether probabilities less than 0.5 should be returned as negative values. |
A numeric vector of surprisal values.
Other residuals:
pextreme()
sextreme(seq(0.1, 0.9, by = 0.1)) sextreme(seq(0.1, 0.9, by = 0.1), directional = TRUE)sextreme(seq(0.1, 0.9, by = 0.1)) sextreme(seq(0.1, 0.9, by = 0.1), directional = TRUE)
Skewness
skewness(x, na_rm = FALSE)skewness(x, na_rm = FALSE)
x |
A numeric object of MCMC values. |
na_rm |
A flag specifying whether to remove missing values. |
A number.
Other summary:
direction(),
directional_information(),
kurtosis(),
lower(),
probability_direction(),
pvalue(),
pzeros(),
svalue(),
upper(),
variance(),
xtr_mean(),
xtr_median(),
xtr_sd(),
zeros(),
zscore()
skewness(1:10)skewness(1:10)
Step
step(x)step(x)
x |
A numeric atomic object. |
A logical value.
Other translations:
exp10(),
exp2(),
fabs(),
ilog(),
ilog10(),
ilog2(),
ilogit(),
inv_logit(),
invlogit(),
log10<-(),
log2<-(),
log<-(),
logit(),
logit<-(),
phi(),
pow()
step(1)step(1)
The surprisal value
(Greenland 2019) is a probability expressed in terms of how many consecutive
heads would have to be thrown on a fair coin in a single attempt to achieve
the same probability: , where is the p-value of
interest. See the details section for some examples.
svalue(x, side = "both", threshold = 0, na_rm = FALSE) p2svalue(p)svalue(x, side = "both", threshold = 0, na_rm = FALSE) p2svalue(p)
x |
A numeric object of MCMC values. |
side |
A character indicating whether to calculate s-values using
p-values for the left tail ( |
threshold |
A number of the threshold value. |
na_rm |
A flag specifying whether to remove missing values. |
p |
A numeric vector of probabilities. |
A near-certain event has an s-value near 0 because it is similar to getting 0 successful coin flips out of 0 tosses, which is certain and unsurprising.
An event with a probability of 0.5 is as surprising as getting a successful coin toss.
A near-impossible event has a very large s-value because its occurrence would be extremely surprising, like observing many consecutive successes on a fair coin.
A non-negative number.
If x has NA values but na_rm is FALSE, returns NA_real.
svalue(): Calculate an s-value from a posterior distribution.
p2svalue(): Calculate an s-value from a vector of probabilities.
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. doi:10.1080/00031305.2018.1529625.
Other summary:
direction(),
directional_information(),
kurtosis(),
lower(),
probability_direction(),
pvalue(),
pzeros(),
skewness(),
upper(),
variance(),
xtr_mean(),
xtr_median(),
xtr_sd(),
zeros(),
zscore()
svalue(as.numeric(0:100)) svalue(as.numeric(0:100), side = "left") svalue(as.numeric(0:100), side = "right") svalue(rnorm(1e4, mean = 1), side = "left") svalue(rnorm(1e4, mean = 1), side = "right") p2svalue(seq(0, 1, by = 0.1))svalue(as.numeric(0:100)) svalue(as.numeric(0:100), side = "left") svalue(as.numeric(0:100), side = "right") svalue(rnorm(1e4, mean = 1), side = "left") svalue(rnorm(1e4, mean = 1), side = "right") p2svalue(seq(0, 1, by = 0.1))
Calculates the quantile-based upper credible limit.
upper(x, conf_level = 0.95, na_rm = FALSE)upper(x, conf_level = 0.95, na_rm = FALSE)
x |
A numeric vector of MCMC values. |
conf_level |
A numeric scalar between 0 and 1 specifying the confidence level. |
na_rm |
A flag specifying whether to remove missing values. |
By default it returns the 95% credible limit which corresponds to the 97.5% quantile.
A number.
Other summary:
direction(),
directional_information(),
kurtosis(),
lower(),
probability_direction(),
pvalue(),
pzeros(),
skewness(),
svalue(),
variance(),
xtr_mean(),
xtr_median(),
xtr_sd(),
zeros(),
zscore()
upper(as.numeric(0:100))upper(as.numeric(0:100))
Variance
variance(x, na_rm = FALSE)variance(x, na_rm = FALSE)
x |
A numeric object of MCMC values. |
na_rm |
A flag specifying whether to remove missing values. |
A number.
Other summary:
direction(),
directional_information(),
kurtosis(),
lower(),
probability_direction(),
pvalue(),
pzeros(),
skewness(),
svalue(),
upper(),
xtr_mean(),
xtr_median(),
xtr_sd(),
zeros(),
zscore()
variance(1:10)variance(1:10)
Mean
xtr_mean(x, na_rm = FALSE)xtr_mean(x, na_rm = FALSE)
x |
A numeric object of MCMC values. |
na_rm |
A flag specifying whether to remove missing values. |
A number.
Other summary:
direction(),
directional_information(),
kurtosis(),
lower(),
probability_direction(),
pvalue(),
pzeros(),
skewness(),
svalue(),
upper(),
variance(),
xtr_median(),
xtr_sd(),
zeros(),
zscore()
xtr_mean(1:10)xtr_mean(1:10)
Median
xtr_median(x, na_rm = FALSE)xtr_median(x, na_rm = FALSE)
x |
A numeric object of MCMC values. |
na_rm |
A flag specifying whether to remove missing values. |
A number.
Other summary:
direction(),
directional_information(),
kurtosis(),
lower(),
probability_direction(),
pvalue(),
pzeros(),
skewness(),
svalue(),
upper(),
variance(),
xtr_mean(),
xtr_sd(),
zeros(),
zscore()
xtr_mean(1:10)xtr_mean(1:10)
Standard Deviation
xtr_sd(x, na_rm = FALSE)xtr_sd(x, na_rm = FALSE)
x |
A numeric object of MCMC values. |
na_rm |
A flag specifying whether to remove missing values. |
A number.
Other summary:
direction(),
directional_information(),
kurtosis(),
lower(),
probability_direction(),
pvalue(),
pzeros(),
skewness(),
svalue(),
upper(),
variance(),
xtr_mean(),
xtr_median(),
zeros(),
zscore()
xtr_sd(1:10)xtr_sd(1:10)
The number of zeros in an numeric object.
zeros(x, na_rm = FALSE)zeros(x, na_rm = FALSE)
x |
A numeric object of MCMC values. |
na_rm |
A flag specifying whether to remove missing values. |
A non-negative integer.
Other summary:
direction(),
directional_information(),
kurtosis(),
lower(),
probability_direction(),
pvalue(),
pzeros(),
skewness(),
svalue(),
upper(),
variance(),
xtr_mean(),
xtr_median(),
xtr_sd(),
zscore()
zeros(c(0:2))zeros(c(0:2))
The Bayesian z-score is here defined as the number of standard deviations from the mean estimate to zero.
zscore(x, na_rm = FALSE)zscore(x, na_rm = FALSE)
x |
A numeric object of MCMC values. |
na_rm |
A flag specifying whether to remove missing values. |
A number.
Other summary:
direction(),
directional_information(),
kurtosis(),
lower(),
probability_direction(),
pvalue(),
pzeros(),
skewness(),
svalue(),
upper(),
variance(),
xtr_mean(),
xtr_median(),
xtr_sd(),
zeros()
zscore(as.numeric(0:100))zscore(as.numeric(0:100))