
Expand declared non-normal random effect distributions into a model
Source:R/etaDist.R
rxEtaDistExpand.RdRewrites a ui that carries dist() declarations into an ordinary ui:
the declared random effects become latent standard normals (a fixed
identity omega) plus unconstrained correlation thetas, and the model
block gains the phiU() + inverse CDF lines that recreate them under
their original names. Everything downstream – rxSolve(), and every
nlmixr2est estimation method – then sees a model it already knows how
to handle.
Usage
rxEtaDistExpand(ui, param = c("cdf", "direct"))Arguments
- ui
rxode2 ui
- param
How a declared random effect is represented for estimation.
"cdf"(default) is the construction described above: a standard normal latent,phiU(), the family's inverse CDF, andrxCor.*carrying a Gaussian copula. The estimator then sees an ordinary model with a fixed identity omega, and the non-normality lives in a decoder line."direct"leaves the declared random effect ALONE: no latent, no decoder, nophiU(). The eta itself is what the estimator samples or optimizes, and it carries the declared family as its prior rather than a variance. Its omega entry is a FIXED placeholder that an estimator on this route must ignore – an estimator that reads it as a Gaussian variance will silently fit the wrong model, so the route is opt-in per estimator.The two are not interchangeable everywhere. For a CORRELATED block of declared random effects the CDF construction is not an alternative, it is the definition: a Gaussian copula with non-normal marginals IS
eta = Q(phi(z)). Expressing that directly needs an explicit joint distribution (NoLimits.jl reaches forCopulas.SklarDist), which this does not have, so"direct"refuses a correlated declared block by name rather than dropping the correlation silently.
Examples
# \donttest{
if (requireNamespace("lotri", quietly = TRUE) &&
"lotriEtaDists" %in% getNamespaceExports("lotri")) {
one.cmt <- function() {
ini({
lclm <- log(5)
lclrv <- log(0.09)
tv <- 3.45
eta.v ~ 0.1
dist(eta.cl) ~ dgamma(shape=1/exp(lclrv),
rate=1/(exp(lclrv)*exp(lclm)))
add.sd <- 0.7
})
model({
cl <- eta.cl
v <- exp(tv + eta.v)
linCmt() ~ add(add.sd)
})
}
rxEtaDistExpand(one.cmt())
}
# }