Skip to contents

Solves object as rxSolve() would, then appends rx__sens_<state>_BY_<param>__ columns computed via adjoint (backward) sensitivity analysis. Same column names and output structure as rxSolve(object, ..., calcSens=). Prefer .rxAdjointGrad() when only a scalar objective gradient is needed.

Usage

rxSolveAdjoint(
  object,
  params,
  events,
  calcSens,
  adjStates = NULL,
  denseBy = 0.01,
  atol = 1e-08,
  rtol = 1e-06,
  ...
)

Arguments

object

model definition accepted by rxode2().

params

named numeric vector of parameter values.

events

event table / data used to define dosing and sampling times; sampling (evid==0) times become the sensitivity output times.

calcSens

character vector of parameter names to differentiate with respect to.

adjStates

character vector of output states of interest; defaults to all ODE states (full forward-sensitivity parity).

denseBy, atol, rtol

passed to the adjoint checkpoint solve; see .rxAdjointSolveEvalC().

...

additional arguments passed to the primal rxSolve() call.

Value

the standard rxSolve() output (as returnType="data.frame") with rx__sens_<state>_BY_<param>__ columns appended.

Author

Matthew L. Fidler

Examples

# \donttest{
pk <- function() {
  model({
    d/dt(depot) <- -ka * depot
    d/dt(central) <- ka * depot - cl / v * central
  })
}
ev <- et(amt = 100, cmt = "depot") |> et(c(1, 2, 4, 8, 12))
rxSolveAdjoint(pk, c(ka = 1.2, cl = 3.5, v = 25), ev,
               calcSens = c("ka", "cl"))
#>  
#>  
#> ℹ parameter labels from comments are typically ignored in non-interactive mode
#> ℹ Need to run with the source intact to parse comments
#>  
#>  
#>  
#>  
#>   time        depot  central rx__sens_depot_BY_ka__ rx__sens_central_BY_ka__
#> 1    1 3.011950e+01 64.32037          -3.011978e+01                27.018487
#> 2    2 9.071810e+00 75.29045          -1.814381e+01                12.253374
#> 3    4 8.229741e-01 63.73351          -3.291938e+00                -3.288056
#> 4    8 6.772834e-03 36.92967          -5.418364e-02                -4.003295
#> 5   12 5.573829e-05 21.09888          -6.688765e-04                -2.321474
#>   rx__sens_depot_BY_cl__ rx__sens_central_BY_cl__
#> 1                      0                -1.509501
#> 2                      0                -4.003651
#> 3                      0                -7.941363
#> 4                      0               -10.426360
#> 5                      0                -9.331300
# }