PCMAddPrior: Add a prior to a PCM object

Description Usage Arguments Value Examples

View source: R/PCMPrior.R

Description

Add a prior to a PCM object

Usage

1
PCMAddPrior(o, member = "", enclos = "?", prior, inplace = TRUE)

Arguments

o

a PCM object.

member

a member expression. Member expressions are character strings denoting named elements in a list object (see examples). Default: "".

enclos

a character string containing the special symbol '?'. This symbol is to be replaced by matching expressions. The result of this substitution can be anything but, usually would be a valid R expression. Default: "?".

prior

a prior object.

inplace

logical (TRUE by default) indicating if the attribute should be set to the object in the current environment, or a modified object should be returned.

Value

if inplace is TRUE (default) nothing is returned. Otherwise, a modified version of o is returned.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
library(PCMBase)
model <- PCMBaseTestObjects$model_MixedGaussian_ab

PCMAddPrior(
  model,
  prior = ParameterPrior(
    d = "dunif", r = "runif",
    p = list(min = PCMParamGetShortVector(PCMParamLowerLimit(model)),
             max = PCMParamGetShortVector(PCMParamUpperLimit(model)))))

PCMAddPrior(
  model, "a$Sigma_x", enclos = "diag(?[,,1])",
  prior = ParameterPrior(
    d = "dunif", r = "runif",
    p = list(min = c(0.2, 0.1, 0.1), max = c(5, 5, 5))))

modelPrior <- PCMPrior(model)
vec <- PCMParamGetShortVector(model)
PriorDensity(modelPrior, vec)

venelin/PCMBayes documentation built on Dec. 23, 2019, 6:39 p.m.