Control for lbfgsb3c estimation method in nlmixr2
Usage
lbfgsb3cControl(
trace = 0,
factr = 1e+07,
pgtol = 0,
abstol = 0,
reltol = 0,
lmm = 5L,
maxit = 10000L,
returnLbfgsb3c = FALSE,
stickyRecalcN = 4,
maxOdeRecalc = 5,
odeRecalcFactor = 10^(0.5),
indTolRelax = TRUE,
useColor = NULL,
printNcol = NULL,
print = 1L,
normType = c("rescale2", "mean", "rescale", "std", "len", "constant"),
scaleType = c("nlmixr2", "norm", "mult", "multAdd"),
scaleCmax = 1e+05,
scaleCmin = 1e-05,
scaleC = NULL,
scaleTo = 1,
gradTo = 1,
rxControl = NULL,
optExpression = TRUE,
sumProd = FALSE,
literalFix = TRUE,
literalFixRes = TRUE,
addProp = c("combined2", "combined1"),
eventSens = c("jump", "fd"),
sensMethod = c("default", "forward", "adjoint"),
calcTables = TRUE,
compress = FALSE,
covMethod = c("r", ""),
adjObf = TRUE,
ci = 0.95,
sigdig = 4,
sigdigTable = NULL,
...
)Arguments
- trace
If positive, print tracing information; higher values give more detail (see source for "L-BFGS-B" trace levels).
- factr
Convergence tolerance factor for "L-BFGS-B"; converges when the objective reduction is within this factor of machine tolerance (default 1e7, i.e. ~1e-8).
- pgtol
Tolerance on the projected gradient for "L-BFGS-B"; 0 (default) suppresses the check.
- abstol
Absolute x-value tolerance for "L-BFGS-B"; 0 (default) suppresses the check.
- reltol
Relative x-value tolerance for "L-BFGS-B"; 0 (default) suppresses the check.
- lmm
Number of BFGS updates retained in "L-BFGS-B" (default 5).
- maxit
maximum number of iterations.
- returnLbfgsb3c
return the lbfgsb3c output instead of the nlmixr2 fit
- stickyRecalcN
The number of bad ODE solves before reducing the atol/rtol for the rest of the problem.
- maxOdeRecalc
Maximum number of times to reduce the ODE tolerances and try to resolve the system if there was a bad ODE solve.
- odeRecalcFactor
The ODE recalculation factor when ODE solving goes bad, this is the factor the rtol/atol is reduced
- indTolRelax
When `TRUE` (default), only subjects whose ODE solve produced NaN/Inf have their tolerances relaxed, and the relaxed tolerance persists across optimizer calls (sticky). When `FALSE`, all subjects have their tolerances relaxed on each retry and tolerances are reset afterward.
- useColor
Logical (or `NULL`) emit ANSI bold/color escapes in the iteration print. `NULL` (default) defers to [crayon::has_color()].
- printNcol
Integer (or `NULL`) parameter columns per row before wrapping. `NULL` (default) uses `floor((getOption("width") - 23) / 12)`.
Either a scalar print-frequency (`0` = suppress, `1` (default) = every evaluation, `N` = every Nth), OR a pre-built [iterPrintControl()] object. Equivalent to `iterPrintControl(every = print, ncol = printNcol, useColor = useColor)`.
- normType
Parameter normalization/scaling used to get scaled initial values for
scaleType, of the formVscaled = (Vunscaled-C1)/C2(see Feature Scaling;rescale2follows the OptdesX manual):"rescale2"scales all parameters to (-1, 1);"rescale"(min-max) scales to (0, 1);"mean"centers on the mean with range (0, 1);"std"standardizes by mean/sd;"len"scales to unit (Euclidean) length;"constant"performs no normalization (C1=0,C2=1).- scaleType
The scaling scheme for nlmixr2:
"nlmixr2"(default) scales as(current-init)*scaleC[i] + scaleTo, withscaleTofromnormTypeand scales fromscaleC;"norm"uses the simple scaling fromnormType;"mult"scales multiplicatively ascurrent/init*scaleTo;"multAdd"scales linearly ((current-init)+scaleTo) for parameters in an exponential block (e.g.exp(theta)) and multiplicatively otherwise.- scaleCmax
Maximum value of the scaleC to prevent overflow.
- scaleCmin
Minimum value of the scaleC to prevent underflow.
- scaleC
Scaling constant used with
scaleType="nlmixr2"; when not specified, chosen by parameter type to keep gradient sizes similar on a log scale: `1` for exp()-transformed/power/boxCox/ yeoJohnson parameters, `0.5*abs(est)` for additive/proportional/ lognormal error parameters, `abs(1/digamma(est+1))` for factorials, and `log(abs(est))*abs(est)` for log-scale parameters. May be set explicitly per parameter if these defaults don't apply well.- scaleTo
Scale the initial parameter estimate to this value. By default this is 1. When zero or below, no scaling is performed.
- gradTo
this is the factor that the gradient is scaled to before optimizing. This only works with scaleType="nlmixr2".
- rxControl
`rxode2` ODE solving options during fitting, created with `rxControl()`
- optExpression
Optimize the rxode2 expression to speed up calculation. By default this is turned on.
- sumProd
Is a boolean indicating if the model should change multiplication to high precision multiplication and sums to high precision sums using the PreciseSums package. By default this is
FALSE.- literalFix
boolean, substitute fixed population values as literals and re-adjust ui and parameter estimates after optimization; Default is `TRUE`.
- literalFixRes
boolean, substitute fixed population values as literals and re-adjust ui and parameter estimates after optimization; Default is `TRUE`.
- addProp
Type of additive-plus-proportional error: `"combined1"`, where standard deviations add: $$y = f + (a + b\times f^c) \times \varepsilon$$; or `"combined2"`, where variances add: $$y = f + \sqrt{a^2 + b^2\times f^{2\times c}} \times \varepsilon$$. Here y = observed, f = predicted, a = additive sd, b = proportional/power sd, c = power exponent (1 in the proportional case).
- eventSens
Controls how dosing/event-parameter (`alag`, `F`, `rate`, `dur`) sensitivities are computed for THETA/ETA gradients: `"jump"` (default) uses rxode2's analytic event sensitivities; `"fd"` uses the legacy finite-difference behavior.
- sensMethod
Method used to compute the ODE parameter sensitivities: `"default"` (the default) defers to the global option `getOption("nlmixr2est.adjoint")` (itself `"forward"` by default); `"forward"` uses the classic variational (forward) sensitivity ODEs; `"adjoint"` uses the in-engine discrete adjoint with the matching adjoint (`s`) method.
- calcTables
This boolean is to determine if the foceiFit will calculate tables. By default this is
TRUE- compress
Should the object have compressed items
- covMethod
Method for calculating the covariance.
"analytic"(the default) uses the exact analytic observed-information R-matrix (reported as \(R^{-1}\)) and additionally returns the residual andOmegastandard errors; it covers FOCEI/FOCE fits with additive, proportional, or combined error, mu-referenced/covariate/other structural parameters (and non-mu-referenced etas), and SD-scale inter-occasion variability, and emits a message and falls back to the finite-difference Hessian for anything out of scope (FO,nAGQ > 1, censoring, DV-transformed error, bounded-parameter transforms, a structural theta shared by two etas, non-SDiovXform, or a pure-proportional variance that vanishes at a near-zero prediction). The finite-difference methods use R (the Hessian) and S (the sum of individual gradient cross-products at the empirical Bayes estimates):"r,s"sandwich (solve(R)%*%S%*%solve(R)),"r"Hessian-based (solve(R)),"s"cross-product-based (solve(S)), or""to skip the covariance step.- adjObf
is a boolean to indicate if the objective function should be adjusted to be closer to NONMEM's default objective function. By default this is
TRUE- ci
Confidence level for some tables. By default this is 0.95 or 95% confidence.
- sigdig
Optimization significant digits; controls the inner/outer optimization tolerance (
10^-sigdig), ODE solver tolerance (0.5*10^(-sigdig-2), or0.5*10^(-sigdig-1.5)for sensitivity/steady-state with liblsoda), and boundary check tolerance (5*10^(-sigdig+1)).- sigdigTable
Significant digits in the final output table. If not specified, then it matches the significant digits in the `sigdig` optimization algorithm. If `sigdig` is NULL, use 3.
- ...
Ignored parameters
Examples
# \donttest{
# A logit regression example with emax model
dsn <- data.frame(i=1:1000)
dsn$time <- exp(rnorm(1000))
dsn$DV=rbinom(1000,1,exp(-1+dsn$time)/(1+exp(-1+dsn$time)))
mod <- function() {
ini({
E0 <- 0.5
Em <- 0.5
E50 <- 2
g <- fix(2)
})
model({
v <- E0+Em*time^g/(E50^g+time^g)
ll(bin) ~ DV * v - log(1 + exp(v))
})
}
fit2 <- nlmixr(mod, dsn, est="lbfgsb3c")
#>
#>
#>
#>
#> ℹ parameter labels from comments are typically ignored in non-interactive mode
#> ℹ Need to run with the source intact to parse comments
#> → loading into symengine environment...
#> → pruning branches (`if`/`else`) of population log-likelihood model...
#> ✔ done
#> → calculate ∂(f)/∂(θ)
#> → finding duplicate expressions in nlm llik gradient...
#> → optimizing duplicate expressions in nlm llik gradient...
#> → finding duplicate expressions in nlm pred-only...
#> → optimizing duplicate expressions in nlm pred-only...
#>
#>
#>
#>
#> → calculating covariance
#> ✔ done
#> → loading into symengine environment...
#> → pruning branches (`if`/`else`) of full model...
#> ✔ done
#> → finding duplicate expressions in EBE model...
#> → optimizing duplicate expressions in EBE model...
#> → compiling EBE model...
#>
#>
#> ✔ done
#> → Calculating residuals/tables
#> ✔ done
print(fit2)
#> ── nlmixr² log-likelihood lbfgsb3c ──
#>
#> OBJF AIC BIC Log-likelihood Condition#(Cov) Condition#(Cor)
#> lPop -704.4138 1139.463 1154.187 -566.7316 3319.747 164.2639
#>
#> ── Time (sec $time): ──
#>
#> setup optimize covariance preprocess postprocess table compress
#> elapsed 0.3344189 1.327431 7.952e-06 0.039 0.012 0.025 0.001
#> other
#> elapsed 0.08514241
#>
#> ── ($parFixed or $parFixedDf): ──
#>
#> Est. SE %RSE Back-transformed(95%CI) BSV(SD) Shrink(SD)%
#> E0 -0.627 0.2189 34.92 -0.627 (-1.056, -0.1979)
#> Em 9.06 7.546 83.29 9.06 (-5.729, 23.85)
#> E50 4.027 2.418 60.04 4.027 (-0.7119, 8.766)
#> g 2 FIXED FIXED 2
#>
#> Covariance Type ($covMethod): r
#> Censoring ($censInformation): No censoring
#> Minimization message ($message):
#> CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH
#>
#> ── Fit Data (object is a modified tibble): ──
#> # A tibble: 1,000 × 5
#> ID TIME DV IPRED v
#> <fct> <dbl> <dbl> <dbl> <dbl>
#> 1 1 0.0249 0 -0.428 -0.627
#> 2 1 0.0403 0 -0.428 -0.626
#> 3 1 0.0864 1 -1.05 -0.623
#> # ℹ 997 more rows
# you can also get the nlm output with fit2$lbfgsb3c
fit2$lbfgsb3c
#> $par
#> E0 Em E50
#> -0.6270132 9.0601102 4.0272143
#>
#> $grad
#> [1] 2.919944e-08 -1.162765e-07 1.310491e-07
#>
#> $value
#> [1] 566.7316
#>
#> $counts
#> [1] 19 19
#>
#> $convergence
#> [1] 0
#>
#> $message
#> [1] "CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH"
#>
#> $scaleC
#> [1] 0.00289795 0.04009648 0.03492545
#>
#> $par.scaled
#> E0 Em E50
#> -389.90016 212.48784 59.04404
#>
#> $hessian
#> E0 Em E50
#> E0 0.001657843 0.001575858 -0.005137211
#> Em 0.001575858 0.003667536 -0.010625243
#> E50 -0.005137211 -0.010625243 0.031950367
#>
#> $cov.scaled
#> E0 Em E50
#> E0 5707.768 5643.188 2794.404
#> Em 5643.188 35416.278 12685.200
#> E50 2794.404 12685.200 4793.021
#>
#> $r
#> E0 Em E50
#> E0 0.0008289213 0.0007879291 -0.002568605
#> Em 0.0007879291 0.0018337679 -0.005312621
#> E50 -0.0025686054 -0.0053126214 0.015975184
#>
# The nlm control has been modified slightly to include
# extra components and name the parameters
# }
