prior: Prior Distribution

Description Usage Arguments Details Value Examples

View source: R/prior.R

Description

Defines a prior distribution/probability density function for the average effect size d or for the heterogeneity of effect sizes τ.

Usage

1
2
3
4
5
6
7
8
prior(
  family,
  param,
  lower,
  upper,
  label = "d",
  rel.tol = .Machine$double.eps^0.5
)

Arguments

family

a character value defining the distribution family.

param

numeric parameters for the distribution. See details for the definition of the parameters of each family.

lower

lower boundary for truncatation of prior density. If family="beta", the interval [0,1] is rescaled to the interval [lower,upper]. Must be specified if family = "custom".

upper

See lower.

label

optional: parameter label.

rel.tol

relative tolerance used for integrating the density of family="custom".

Details

The following prior distributions are currently implemented:

Value

an object of the class prior: a density function with the arguments x (parameter values) and log (whether to return density or log-density).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
### Half-Normal Distribution
p1 <- prior("norm", c(mean = 0, sd = .3), lower = 0)
p1
p1(c(-1, 1, 3))
plot(p1, -.1, 1)

### Half-Cauchy Distribution
p2 <- prior("cauchy", c(location = 0, scale = .3), lower = 0)
plot(p2, -.5, 3)

### Custom Prior Distribution
p3 <- prior("custom", function(x) x^2, 0, 1)
plot(p3, -.1, 1.2)

metaBMA documentation built on March 17, 2021, 9:06 a.m.