Learn R Programming

bayestestR (version 0.2.0)

p_map: Bayesian p-value based on the density at the Maximum A Priori (MAP)

Description

Compute a Bayesian equivalent of the p-value, related to the odds that a parameter (described by its posterior distribution) has against the null hypothesis (h0) using Mills' (2014, 2017) Objective Bayesian Hypothesis Testing framework. It is mathematically based on the density at the Maximum A Priori (MAP) and corresponds to the density value at 0 divided by the density of the MAP estimate.

Usage

p_map(x, ...)

# S3 method for numeric p_map(x, precision = 2^10, ...)

# S3 method for stanreg p_map(x, precision = 2^10, effects = c("fixed", "random", "all"), parameters = NULL, ...)

# S3 method for brmsfit p_map(x, precision = 2^10, effects = c("fixed", "random", "all"), component = c("conditional", "zi", "zero_inflated", "all"), parameters = NULL, ...)

# S3 method for BFBayesFactor p_map(x, precision = 2^10, ...)

Arguments

x

Vector representing a posterior distribution. Can also be a stanreg or brmsfit model.

...

Currently not used.

precision

Number of points for density estimation. See the n-parameter in density.

effects

Should results for fixed effects, random effects or both be returned? Only applies to mixed models. May be abbreviated.

parameters

Regular expression pattern that describes the parameters that should be returned. Meta-parameters (like lp__ or prior_) are filtered by default, so only parameters that typically appear in the summary() are returned. Use parameters to select specific parameters for the output.

component

Should results for all parameters, parameters for the conditional model or the zero-inflated part of the model be returned? May be abbreviated. Only applies to brms-models.

References

Mill's talk

Examples

Run this code
# NOT RUN {
library(bayestestR)

p_map(rnorm(1000, 0, 1))
p_map(rnorm(1000, 10, 1))

library(rstanarm)
model <- stan_glm(mpg ~ wt + gear, data = mtcars, chains = 2, iter = 200)
p_map(model)

# }
# NOT RUN {
library(brms)
model <- brms::brm(mpg ~ wt + cyl, data = mtcars)
p_map(model)

library(BayesFactor)
bf <- ttestBF(x = rnorm(100, 1, 1))
p_map(bf)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab