Add a prior to a PCM object
PCMAddPrior(o, member = "", enclos = "?", prior, inplace = TRUE)
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. |
if inplace is TRUE (default) nothing is returned. Otherwise, a
modified version of o
is returned.
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)#> [1] -142.3039 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 #> [8] 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 #> [15] 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 #> [22] 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 #> [29] 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 #> [36] 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 #> [43] 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 #> [50] 0.0000 0.0000