init_theta: Get/set initial parameters

View source: R/init_funs.R

init_thetaR Documentation

Get/set initial parameters

Description

[Stable]

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

Usage

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.

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.

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.

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
init_omega(m1) ## display current $OMEGA in tibble-form


## here we supply a named vector in a different order
m1 <- m1 %>% init_theta(init = c(KA = -2, V = 1))
m1 %>% dollar("THETA")

## 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")

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

m1 %>% dollar("THETA")


NMproject documentation built on Sept. 30, 2022, 1:06 a.m.