%~% | R Documentation |
Distributional assignment operator
x %~% distr
x |
LHS; Random effect or data for which distribution assignment applies |
distr |
RHS; Distribution expression |
Provides a slightly simplified syntax inspired by, but not compatible with, other probabilistic programming languages (e.g. BUGS/JAGS):
x %~% distribution(...)
is syntactic sugar for .nll <- .nll - sum(distribution(x,...,log=TRUE))
The variable .nll
is automatically initialized to 0
and returned on exit.
The updated value of the hidden variable .nll
.
If the shorter name ~
is preferred, it can be locally overloaded using "~" <- RTMB::"%~%"
.
f <- function(parms) {
getAll(parms)
x %~% dnorm(mu, 1)
y %~% dpois(exp(x))
}
p <- list(mu=0, x=numeric(10))
y <- 1:10
obj <- MakeADFun(f, p, random="x")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.