The goal was to return an object that looked similar to param_estimates(). The internal function get_initial_est(), returns all values (i.e. the full diagonally concatenated OMEGA matrix if multiple records are provided) in a list format, whereas the wrapper initial_estimates(), only displays values defined in the control stream file
`initial_estimates()` example
```r
MOD1 <- read_model(
system.file("model", "nonmem", "basic", "1", package = "bbr")
)
> initial_estimates(MOD1, flag_fixed = TRUE)
# A tibble: 8 × 7
parameter_names init lower_bound upper_bound fixed record_type record_number
1 THETA(1) 2 0 NA FALSE theta 1
2 THETA(2) 3 0 NA FALSE theta 1
3 THETA(3) 10 0 NA FALSE theta 1
4 THETA(4) 0.02 NA NA FALSE theta 1
5 THETA(5) 1 NA NA FALSE theta 1
6 OMEGA(1,1) 0.05 NA NA FALSE omega 1
7 OMEGA(2,2) 0.2 NA NA FALSE omega 1
8 SIGMA(1,1) 1 NA NA TRUE sigma 1
```
If you would like to format OMEGA or SIGMA records as full matrices, they are stored as attributes:
```r
initial_est <- initial_estimates(.mod)
attr(initial_est, "omega_mat")
attr(initial_est, "sigma_mat")
# Run
> attr(initial_est, "omega_mat")
[,1] [,2]
[1,] 0.05 NA
[2,] NA 0.2
```
Tweaking initial estimates
Usage
MOD1 <- read_model(
system.file("model", "nonmem", "basic", "1", package = "bbr")
)
# Base usage
mod2 <- copy_model_from(MOD1, "mod2") %>%
tweak_initial_estimates(.p = 0.2)
# This function may be paired with `inherit_param_estimates()`:
mod2 <- copy_model_from(MOD1, "mod2") %>%
inherit_param_estimates() %>% tweak_initial_estimates(.p = 0.2)
Walkthrough
### Starting Record
```
;Initial THETAs
$THETA
(0,,1) ;[LCLM2]
( 0.7 FIX) ;[LCLM]
(0.67, 0.7, 0.72) ;[LCLF]
( 2 ) ;[CLAM]
( 2.0);[CLAF]
( 0.7 ) ;[LV1M]
( 0.7 ) ;[LV1F]
( 2.0 ) ;[V1AM]
( 2.0 ) ;[V1AF]
( 0.7 ) ;[MU_3]
( 0.7 );[MU_4]
( 0.3 ) ;[SDSL]
```
### Tweak values
```r
tweak_initial_estimates(
.mod
.p = 0.1,
digits = 2
)
```
### After Tweaking
```
;Initial THETAs
$THETA
(0,,1) ;[LCLM2] # If no estimate is found, treat as fixed (skip)
( 0.7 FIX) ;[LCLM] # skip fixed parameters
(0.67, 0.72, 0.72) ;[LCLF] # If tweaked value would be outside of one of the bounds, set to the bound
( 1.9 ) ;[CLAM] # Otherwise tweak the value by the sampled percentage
( 2.1);[CLAF]
( 0.76 ) ;[LV1M]
( 0.67 ) ;[LV1F]
( 2.2 ) ;[V1AM]
( 1.8 ) ;[V1AF]
( 0.73 ) ;[MU_3]
( 0.68 );[MU_4]
( 0.27 ) ;[SDSL]
```
See previous discussions here: https://github.com/metrumresearchgroup/bbr/pull/635
Getting initial parameter estimates
The goal was to return an object that looked similar to
param_estimates()
. The internal functionget_initial_est()
, returns all values (i.e. the full diagonally concatenatedOMEGA
matrix if multiple records are provided) in a list format, whereas the wrapperinitial_estimates()
, only displays values defined in the control stream file`initial_estimates()` example
```r MOD1 <- read_model( system.file("model", "nonmem", "basic", "1", package = "bbr") ) > initial_estimates(MOD1, flag_fixed = TRUE) # A tibble: 8 × 7 parameter_names init lower_bound upper_bound fixed record_type record_numberTweaking initial estimates
Usage
Walkthrough
### Starting Record ``` ;Initial THETAs $THETA (0,,1) ;[LCLM2] ( 0.7 FIX) ;[LCLM] (0.67, 0.7, 0.72) ;[LCLF] ( 2 ) ;[CLAM] ( 2.0);[CLAF] ( 0.7 ) ;[LV1M] ( 0.7 ) ;[LV1F] ( 2.0 ) ;[V1AM] ( 2.0 ) ;[V1AF] ( 0.7 ) ;[MU_3] ( 0.7 );[MU_4] ( 0.3 ) ;[SDSL] ``` ### Tweak values ```r tweak_initial_estimates( .mod .p = 0.1, digits = 2 ) ``` ### After Tweaking ``` ;Initial THETAs $THETA (0,,1) ;[LCLM2] # If no estimate is found, treat as fixed (skip) ( 0.7 FIX) ;[LCLM] # skip fixed parameters (0.67, 0.72, 0.72) ;[LCLF] # If tweaked value would be outside of one of the bounds, set to the bound ( 1.9 ) ;[CLAM] # Otherwise tweak the value by the sampled percentage ( 2.1);[CLAF] ( 0.76 ) ;[LV1M] ( 0.67 ) ;[LV1F] ( 2.2 ) ;[V1AM] ( 1.8 ) ;[V1AF] ( 0.73 ) ;[MU_3] ( 0.68 );[MU_4] ( 0.27 ) ;[SDSL] ```closes https://github.com/metrumresearchgroup/bbr/issues/632