Skip to contents

rxPriorLogDensity()'s gradOmega is always on the raw omega scale – the prior itself is defined there, for every method (see this file's header comment). A caller whose optimizer varies chol(Omega^-1) internally instead (FOCEI's op_focei.cholOmegaInv, nlmixr2est/src/inner.cpp) still needs that gradient chain-ruled into its own parameterization; a method that estimates Omega directly (SAEM) uses gradOmega as-is and does not need this. This is a thin shim over the pure C++ rxPriorOmegaToCholOmegaInvGrad() (inst/include/rxode2prior.h), exposed the same way for a downstream package's own C++ objective.

Usage

rxPriorOmegaToCholOmegaInvGrad(omega, gradOmega)

Arguments

omega

a single omega block (p x p numeric matrix, positive definite)

gradOmega

the corresponding block of rxPriorLogDensity()'s gradOmega, i.e. gradOmega[block, block] (p x p); need not be symmetric on entry (rxPriorLogDensity()'s own gradOmega always is, but this treats it entrywise and symmetrizes internally either way, since only a symmetric perturbation of omega is ever reachable by varying U)

Value

p x p matrix, the gradient with respect to the upper-triangular free elements of U = chol(solve(omega)) (omega^-1 = t(U) %*% U); its strict lower triangle is exactly 0 since those entries address no free parameter of U. NULL if omega is not positive definite.

Author

Matthew L. Fidler

Examples


# \donttest{
omega <- lotri::lotri(eta.ka + eta.cl ~ c(0.1, 0.01, 0.1))
gradOmega <- matrix(c(1, 0.2, 0.2, -0.5), 2, 2)
rxPriorOmegaToCholOmegaInvGrad(omega, gradOmega)
#>            eta.ka      eta.cl
#> eta.ka -0.0641871 -0.01887856
#> eta.cl  0.0000000  0.02846050
# }