[Stable]

These functions are useful to obtain and modify initial values of $THETA, $OMEGA and $SIGMA.

init_theta(m, replace, ...)

init_omega(m, replace, ...)

init_sigma(m, replace, ...)

Arguments

m

An nm object.

replace

Optional tibble for replacement.

...

Additional arguments for mutating initial estimate NONMEM subroutines. See examples.

Value

If replace is specified returns an nm object with modified ctl_contents field. Otherwise returns a tibble or list of tibbles with initial estimation information.

Details

It's easiest to learn this function by view examples, the vignette and the demo setup_nm_demo(). It is a good idea to view the resulting data.frame to see the columns that are able to be manipulated.

Examples


# create example object m1 from package demo files
exdir <- system.file("extdata", "examples", "theopp", package = "NMproject")
m1 <- new_nm(run_id = "m1", 
             based_on = file.path(exdir, "Models", "ADVAN2.mod"),
             data_path = file.path(exdir, "SourceData", "THEOPP.csv"))


m1 <- m1 %>%
  fill_input() %>%
  init_theta(init = c(-2, 0.5, 1)) %>%
  init_sigma(init = c(0.1, 0.1)) # %>%
  # run_nm()

init_theta(m1) ## display current $THETA in tibble-form
#> $`execute.Models/m1`
#>   name parameter lower init upper theta   FIX unit trans line pos orig_line
#> 2   KA    THETA1    NA -2.0    NA     1 FALSE  h-1   LOG    2   1         2
#> 3    K    THETA2    NA  0.5    NA     2 FALSE  h-1   LOG    3   1         3
#> 4    V    THETA3    NA  1.0    NA     3 FALSE    L   LOG    4   1         4
#> 
init_omega(m1) ## display current $OMEGA in tibble-form
#> $`execute.Models/m1`
#>     name omega1 omega2 lower init upper block mblock   FIX unit trans line pos
#> 1   <NA>     NA     NA    NA   NA    NA     1     NA FALSE <NA>  <NA>    1   1
#> 2 IIV_KA      1      1    NA  0.1    NA     1      1 FALSE <NA>   LOG    2   1
#> 3  IIV_K      2      2    NA  0.1    NA     2      1 FALSE <NA>   LOG    3   1
#> 4  IIV_V      3      3    NA  0.1    NA     3      1 FALSE <NA>   LOG    4   1
#> 5   <NA>     NA     NA    NA   NA    NA    NA     NA FALSE <NA>  <NA>    5   1
#>   orig_line orig_pos
#> 1         1        1
#> 2         2        1
#> 3         3        1
#> 4         4        1
#> 5         5        1
#> 


## here we supply a named vector in a different order
m1 <- m1 %>% init_theta(init = c(KA = -2, V = 1))
m1 %>% dollar("THETA")
#> $`execute.Models/m1`
#>   1| $THETA
#>   2| -2   ; KA ; h-1 ; LOG
#>   3| 0.5   ; K ; h-1 ; LOG
#>   4| 1   ; V ; L ; LOG
#> 

## can also manipulate other aspects (like the FIX column) similarly
m1 <- m1 %>% init_theta(init = c(KA = -2, V = 1),
                        FIX = c(KA = TRUE))
m1 %>% dollar("THETA")
#> $`execute.Models/m1`
#>   1| $THETA
#>   2| -2 FIX   ; KA ; h-1 ; LOG
#>   3| 0.5   ; K ; h-1 ; LOG
#>   4| 1   ; V ; L ; LOG
#> 

## perturb all parameters by ~10%
m1 <- m1 %>% init_theta(init = rnorm(length(init), mean = init, sd = 0.1))

m1 %>% dollar("THETA")
#> $`execute.Models/m1`
#>   1| $THETA
#>   2| -2.0583 FIX   ; KA ; h-1 ; LOG
#>   3| 0.48461   ; K ; h-1 ; LOG
#>   4| 0.86106   ; V ; L ; LOG
#>