Construct a numeric object from initial estimates defined by control stream records:
extract_theta()returns a vector of initial estimates defined byTHETArecords.extract_omega()andextract_sigma()return a matrix of initial estimates forOMEGAandSIGMArecords.
Usage
extract_theta(records, mark_flags = NULL, type = c("init", "low", "up"))
extract_omega(records, mark_flags = NULL)
extract_sigma(records, mark_flags = NULL)Arguments
- records
An nmrec_ctl_records object.
- mark_flags
A vector of NONMEM flags (i.e. valueless options such as
FIXEDorSD). For each specified flag, construct a boolean vector (forTHETA) or matrix (forOMEGAandSIGMA) indicating whether the flag is "active" for the value. Any valid spelling of the flag name is allowed.For example, passing a value of "fix" would indicate whether a
FIXEDflag is in effect for each value. The flag may be linked to an individual initial estimate (e.g.,FIXEDfor aTHETAor diagonalOMEGArecord) or linked to all values in the record (e.g.,FIXEDfor aTHETAor blockOMEGArecord). In either case, the boolean vector or matrix is always the same shape as the return value.The same result will be returned regardless of
type. For example, passingmark_flags = "fix"andtype = "up"would yieldTRUEfor aTHETAinitial estimate of(1,2 FIX).The results are stored in a named list as the "nmrec_flags" attribute attached to the return value, with the names corresponding to the resolved flag names.
- type
Which
THETAvalue to return: initial estimate ("init", the default), the lower bound ("low"), or the upper bound ("up").
Value
A vector (for THETA) or a square matrix (for OMEGA and SIGMA).
For matrix values, the upper triangle is always filled with NA values.
The "nmrec_record_size" attribute attached to the return value indicates the number of values that come from each record. For matrix results, the value corresponds to the size along the diagonal.
Details
Constraints and limitations
These functions return initial estimates only if they are explicitly defined in the control stream. All other values are returned as
NA. For example, a record of$THETA (1)x4is returned asc(1, NA, NA, NA).If additional parameter records are used for priors, those are included in the result. To avoid this, instead use more specific record names (such as
THETAPandTHETAPV).
See also
set_param for setting parameter options from values
Examples
ctl <- parse_ctl(c(
"$PROBLEM ex",
"$THETA 2 FIX",
"$THETA (10,30)x2",
"$OMEGA BLOCK(3)",
"0.1",
"0.01 0.1",
"0.01 0.01 0.1"
))
extract_theta(ctl)
#> [1] 2 30 NA
#> attr(,"nmrec_record_size")
#> [1] 1 2
extract_theta(ctl, type = "low")
#> [1] NA 10 NA
#> attr(,"nmrec_record_size")
#> [1] 1 2
extract_theta(ctl, mark_flags = "fixed")
#> [1] 2 30 NA
#> attr(,"nmrec_record_size")
#> [1] 1 2
#> attr(,"nmrec_flags")
#> attr(,"nmrec_flags")$fixed
#> [1] TRUE FALSE NA
#>
extract_omega(ctl)
#> [,1] [,2] [,3]
#> [1,] 0.10 NA NA
#> [2,] 0.01 0.10 NA
#> [3,] 0.01 0.01 0.1
#> attr(,"nmrec_record_size")
#> [1] 3
