createUniformPrior: Convenience function to create a simple uniform prior...

Description Usage Arguments Note Author(s) See Also Examples

View source: R/classPrior.R

Description

Convenience function to create a simple uniform prior distribution

Usage

1
createUniformPrior(lower, upper, best = NULL)

Arguments

lower

vector of lower prior range for all parameters

upper

vector of upper prior range for all parameters

best

vector with "best" values for all parameters

Note

for details see createPrior

Author(s)

Florian Hartig

See Also

createPriorDensity, createPrior, createBetaPrior, createTruncatedNormalPrior, createBayesianSetup

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
set.seed(1)

prior <- createUniformPrior(lower = c(0,0), upper = c(0.4,5))

# c(2, 3) outside of limits
prior$density(c(2, 3))
# -Inf

# c(0.2, 2) within limits
prior$density(c(0.2, 2))
# -0.6931472


# sample from prior
prior$sampler()
# [1] 0.2291413 4.5410389


## the prior object can be passed to createBayesianSetup()

# log-likelihood density function (needed for createBayesianSetup)
ll <- function(x) sum(dnorm(x, log = TRUE))

setup <- createBayesianSetup(prior = prior, likelihood = ll)

Example output

[1] -Inf
[1] -0.6931472
[1] 0.2291413 4.5410389

BayesianTools documentation built on Dec. 10, 2019, 1:08 a.m.