Learn R Programming

pmxNODE (version 0.1.0)

nn_converter_mlx: NN converter for Monolix

Description

This function converts a Monolix model file that includes pseudo-functions for NNs as described in Details into a model that can be used in Monolix. An example Monolix model can be opened with the function open_mlx_example(). In addition, it allows to generate a Monolix .mlxtran file with automatically initialized parameters and estimation settings.

Usage

nn_converter_mlx(
  mlx_path,
  pop_only = FALSE,
  theta_scale = 0.1,
  eta_scale = 0.1,
  pre_fixef = NULL,
  gen_mlx_file = FALSE,
  mlx_name = NULL,
  data_file = NULL,
  header_types = NULL,
  obs_types = NULL,
  mapping = NULL,
  seed = 1908
)

Value

Saving a converted Monolix model file under mlx_path_converted.txt and optionally a Monolix file (mlx_name.mlxtran) if gen_mlx_file=TRUE

Arguments

mlx_path

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

pop_only

(boolean) If the generated Monolix .mlxtran 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 pre_fixef_extractor_mlx function from a previous Monolix run

gen_mlx_file

(boolean) If a Monolix .mlxtran file with already initialized parameters and estimation settigs should be generated

mlx_name

(string) Optional, name of the generated Monolix file (mlx_name.mlxtran). If no name is given and gen_mlx_file=TRUE, name of the Monolix file will be unconverted_model_name_mlx_file_pop/ind.mlxtran, with pop or ind depending whether pop=TRUE or pop=FALSE,respectively.

data_file

(string) Required if gen_mlx_file=TRUE, (Path/)Name of the data file to be used

header_types

(vector) Required if gen_mlx_file=TRUE, Vector of strings describing column types of data. Possible header types: ignore, id, time, observation, amount, contcov, catcov, occ, evid, mdv, obsid, cens, limit, regressor, nominaltime, admid, rate, tinf, ss, ii, addl, date

obs_types

(list) List of types of observations, e.g., “continuous”; only required if non-continuous observations

mapping

(list) List of mapping between model outputs and observation IDs

seed

(numeric) Seed for random parameter initialization.

Author

Dominic Bräm

Details

An example of model file could look like following

DESCRIPTION:
A Monolix model for conversion
[LONGITUDINAL]
input = {V=2}
PK:
depot(target=C)
EQUATION:
ddt_C = NN1(state=C,min_init=1,max_init=300) +
                amtDose * NN2(state=t,min_init=0.5,max_init=50,time_nn=TRUE)
Cc = C/V
OUTPUT:
output = Cc
  • Note that the parameters in the input need to have an initial value

  • 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 Monolix model file will be saved under unconverted_file_converted.txt

Examples

Run this code
if (FALSE) {
nn_converter_mlx("mlx_model2.txt",
                 pop_only=TRUE,gen_mlx_file=TRUE,
                 data_file="TMDD_dataset.csv",
                 header_types=c("id","time","amount","observation"))

est_parms <- pre_fixef_extractor_mlx("mlx_model2_time_nn_mlx_file_pop.mlxtran")

nn_converter_mlx("mlx_model2.txt",
                 pop_only=FALSE,gen_mlx_file=TRUE,
                 data_file="TMDD_dataset.csv",
                 header_types=c("id","time","amount","observation"),
                 pre_fixef=est_parms)
}

Run the code above in your browser using DataLab