Learn R Programming

BayesTools (version 0.2.18)

prior_functions: Elementary prior related functions

Description

Density (pdf / lpdf), distribution function (cdf / ccdf), quantile function (quant), random generation (rng), mean, standard deviation (sd), and marginal variants of the functions (mpdf, mlpf, mcdf, mccdf, mquant) for prior distributions.

Usage

# S3 method for prior
rng(x, n, ...)

# S3 method for prior cdf(x, q, ...)

# S3 method for prior ccdf(x, q, ...)

# S3 method for prior lpdf(x, y, ...)

# S3 method for prior pdf(x, y, ...)

# S3 method for prior quant(x, p, ...)

# S3 method for prior mcdf(x, q, ...)

# S3 method for prior mccdf(x, q, ...)

# S3 method for prior mlpdf(x, y, ...)

# S3 method for prior mpdf(x, y, ...)

# S3 method for prior mquant(x, p, ...)

Value

pdf (mpdf) and lpdf (mlpdf) give the (marginal) density and the log of (marginal) density, cdf (mcdf) and ccdf (mccdf) give the (marginal) distribution and the complement of (marginal) distribution function, quant (mquant) give the (marginal) quantile function, and rng generates random deviates for an object of class 'prior'.

Arguments

x

prior distribution

n

number of observations

...

unused arguments

q

vector or matrix of quantiles

y

vector of observations

p

vector of probabilities

Examples

Run this code
# create a standard normal prior distribution
p1 <- prior(distribution = "normal", parameters = list(mean = 1, sd = 1))

# generate a random sample from the prior
rng(p1, 10)

# compute cumulative density function
cdf(p1, 0)

# obtain quantile
quant(p1, .5)

# compute probability density
pdf(p1, c(0, 1, 2))

Run the code above in your browser using DataLab