Skip to contents

The one-time, R-only (main-thread) half of the kernel: parses the prior column and hands the result to src/priorDensity.cpp as an rx_prior_spec_t in R vectors owned by the returned R external pointer, which R frees with it. rxPriorLogDensityEval() (inst/include/rxode2prior.h) – reachable through rxode2's C function-pointer table – then evaluates it with no R/Rcpp call of any kind, safe to call from inside an OpenMP-parallel objective/gradient evaluation.

Usage

rxPriorBuildSpec(ui, method = c("general", "nwpri", "tnpri"))

Arguments

ui

rxode2 ui model

method

"general" (default), "nwpri" or "tnpri"; see this file's header comment for what differs

Value

external pointer to a rx_prior_spec_t

Author

Matthew L. Fidler

Examples

# \donttest{
mod <- function() {
  ini({
    tcl <- log(3)
    tv <- log(30)
    add.sd <- c(0, 0.7)
    prior(tcl) ~ dnorm(0, 10)
  })
  model({
    cl <- exp(tcl)
    v <- exp(tv)
    d/dt(central) <- -cl / v * central
    cp <- central / v
    cp ~ add(add.sd)
  })
}
# priors need 'lotri' >= 1.0.5
if (utils::packageVersion("lotri") >= "1.0.5") {
  spec <- rxPriorBuildSpec(mod)
  inherits(spec, "externalptr")
}
#>  
#>  
#> ℹ parameter labels from comments are typically ignored in non-interactive mode
#> ℹ Need to run with the source intact to parse comments
#> [1] TRUE
# }