dprior | R Documentation |
dprior
computes the log-density of a joint prior distribution at a
given set of parameter values. rprior
generates random samples from
the same joint prior specification.
dprior(p_prior_r, parameters_r)
rprior(p_prior_r, n = 1L)
p_prior_r |
A list specifying the prior distribution, typically
constructed using |
parameters_r |
For |
n |
For |
These functions implement the core computations for evaluating and sampling
from a joint prior distribution specified via BuildPrior
:
dprior
: Evaluates the log-density of the joint prior at the
given parameter values.
rprior
: Draws independent samples from the specified joint prior.
The joint prior may include truncated normal, beta, gamma, and other common distributions, possibly bounded by user-specified lower and upper limits.
dprior
A numeric vector of log-density values.
rprior
A numeric matrix of dimension n
× nparameter
,
containing samples from the prior distribution. Each row is one sample.
p0 <- c(A = 0.15, B = 0.45, mean_v = 2.25, sd_v = 0.15, t0 = 0.2)
p1 <- rep(0.1, 5)
p_prior <- BuildPrior(
p0 = p0,
p1 = p1,
lower = rep(NA, 5),
upper = rep(NA, 5),
dist = rep("tnorm", 5),
log_p = rep(TRUE, 5)
)
# Evaluate log-density
parameters <- seq(0.1, 0.5, by = 0.1)
res0 <- dprior(p_prior, parameters)
res1 <- dnorm(parameters, p0, 0.1, TRUE)
print(res0)
print(res1)
# Generate samples from the prior
res2 <- rprior(p_prior, 1)
res3 <- rprior(p_prior, 2)
print(res2)
print(res3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.