Learn R Programming

pmxNODE (version 0.1.0)

nn_converter_nm: NN converter for NONMEM

Description

This function converts a NONMEM model file that includes pseudo-functions for NNs as described in Details into a model that can be used in NONMEM. An example NONMEM model can be opened with the function open_nm_example().

Usage

nn_converter_nm(
  ctl_path,
  pop_only = FALSE,
  theta_scale = 0.1,
  eta_scale = 0.001,
  pre_fixef = NULL,
  seed = 1908
)

Value

Saving a converted NONMEM model file under ctl_path_converted.ctl

Arguments

ctl_path

(string) (Path/)Name of the unconverted NONMEM model file

pop_only

(boolean) If the generated NONMEM model file should be a fit without (TRUE) or with (FALSE) inter-individual variability on NN parameters

theta_scale

(numeric) Scale in which typical NN parameter values are initialized, default is 0.1, i.e., weights are initialized between -0.3 and 0.3

eta_scale

(numeric) Initial standard deviation of random effects on NN parameters, default is 0.1

pre_fixef

(named vector) Specific initial values for typical parameters, can be optained with the nn_prefix_extractor_nm function from the results file of a previous NONMEM run

seed

(numeric) Seed for random parameter initialization.

Author

Dominic Bräm

Details

An example of model file could look like following

$SIZES LVR=80 LNP4=40000
$PROB RUN
$INPUT C ID TIME AMT DV DOSE EVID
$DATA data_example1_nm.csv IGNORE=C
$SUBROUTINES ADVAN13
$MODEL
COMP(Centr)
$PK
lV = THETA(1)
V = lV * EXP(ETA(1))
$DES
DADT(1) = NNc(state=A(1),min_init=0.5,max_init=5) +
               DOSE * NNt(state=T,min_init=1,max_init=5,time_nn=TRUE)
$ERROR
Cc = A(1)/V
Y=Cc*(1+EPS(1)) + EPS(2)
$THETA
2 ; [V]
$OMEGA
0.1 ; [V]
$SIGMA
0.1
0.1
$ESTIMATION METHOD=1 MAXEVAL=9999 INTER PRINT=5
$TABLE ID TIME DV IPRED=CIPRED AMT NOPRINT FILE=nm_example1.tab
  • Note that size of problem should be increased, as in the model above with $SIZES LVR=80 LNP4=40000

  • NN functions need to be of form NNX(...) where X is the name of the NN so references between the same NN, e.g., as output of absorption compartment and input to central compartment, can be made. Arguments to NNX are

    • state= defines the state to be used in the NN. For time, use t.

    • min_init= defines the minimal activation point for the NN, i.e., minimal expected state

    • max_init= defines the maximal activation point for the NN, i.e., maximal expected state

    • n_hidden= (optional) defines the number of neurons in the hidden layer, default is 5

    • act= (optional) defines activation function in the hidden layer, ReLU and Softplus implemented, default is ReLU

    • time_nn= (optional) defines whether the NN should be assumed to be a time-dependent NN and consequently all weights from input to hidden layer should be strictly negative.

Note: Converted NONMEM model file will be saved under unconverted_file_converted.ctl

Examples

Run this code
if (FALSE) {
nn_converter_nm("nm_example_model.ctl",pop_only = TRUE)

est_parms <- pre_fixef_extractor_nm("nm_example_model_converted.res")

nn_converter_nm("nm_example_model.ctl",pop_only = FALSE,pre_fixef=est_parms)
}

Run the code above in your browser using DataLab