set_theta(), set_omega(), and set_sigma() enable updating THETA,
OMEGA, and SIGMA records by specifying a full-length parameter vector or
matrix. These functions handle mapping from the parameter space to the
corresponding option.
Arguments
- records
An nmrec_ctl_records object.
- values
Overwrite the parameter's initial estimates in
recordswith these values. The length must match the full length defined by the combination of the parameter's records.For
THETA,valuesmust be a vector. ForOMEGAandSIGMA,valuescan bethe square matrix, in which case the values in the lower triangle (including the diagonal) are used
a vector in row-major order for values in the lower triangle (including diagonal).
Use
NAinvaluesto skip updating the corresponding option.- fmt
Convert each value to a string with this
sprintf()format specifier.- bounds
Whether to keep or discard the existing bounds when setting the initial estimates in
THETArecords.- representation
Whether to keep alternative representation options like
SDandCORRELATIONor reset to the default representation (variance and covariance).For
OMEGAandSIGMArecords, NONMEM supports specifying diagonal and off-diagonal initial estimates in a different representation than the default, variance and covariance. Ifvaluesare the final estimates from a previous NONMEM run, the alternative representation options should be discarded because NONMEM always outputs variances and covariances.NAvalues can lead to records and options being "untouched" (i.e. not overwritten with the value fromvalues). Even when "reset" is specified, alternative options are not discarded for untouched records (in the case of BLOCK records, where the option applies to all values in the block) or for untouched options (in the case ofDIAGONALrecords, where the options apply to individual initial estimates).
Details
Constraints and limitations
These functions update initial estimates only if they are explicitly defined in the control stream.
For example, consider the update of
$THETA (1)x4. That defines four initial estimates, but only the first explicitly appears. Callingset_theta()with a value ofc(5, 6, 7, 8)gives a result of(5)x4.The caller must specify a value with a size that matches what is defined by the parameter records.
Using additional parameter records for priors is not supported and will lead to a size mismatch between the parameter and its records. Instead use more specific record names (such as
THETAPandTHETAPV).
See also
set_record_option() for setting option by name, extract_param
for getting a vector or matrix of initial estimates
Examples
ctl <- parse_ctl(c(
"$PROBLEM ex",
"$THETA 2",
"$THETA (30)x2",
"$OMEGA BLOCK(3)",
"0.1",
"0.01 0.1",
"0.01 0.01 0.1"
))
set_theta(ctl, c(10, 40, 20))
ctl
#> $PROBLEM ex
#> $THETA 10
#> $THETA (40)x2
#> $OMEGA BLOCK(3)
#> 0.1
#> 0.01 0.1
#> 0.01 0.01 0.1
new_omega <- matrix(
c(
0.5, 0.2, 0.2,
0.2, NA, 0.2,
0.2, 0.2, 0.7
),
nrow = 3, byrow = TRUE
)
# The upper triangle doesn't come into play; let's zero it for clarity, but
# it would be fine to leave as is.
new_omega[upper.tri(new_omega)] <- 0
new_omega
#> [,1] [,2] [,3]
#> [1,] 0.5 0.0 0.0
#> [2,] 0.2 NA 0.0
#> [3,] 0.2 0.2 0.7
set_omega(ctl, new_omega)
ctl
#> $PROBLEM ex
#> $THETA 10
#> $THETA (40)x2
#> $OMEGA BLOCK(3)
#> 0.5
#> 0.2 0.1
#> 0.2 0.2 0.7
