# METHOD_OPTIONS

Type: dict_record

method options for tut_script

Example:-

    METHOD_OPTIONS:
        py_module: tut
        rand_seed: 12345
        float_format: default

## py_module

Type: one_of(tut)

Python module required to process this script file

Example:-

    py_module: tut

## rand_seed

Type: int / auto

Option to set seed to make run result reproducible -e.g. when debugging.

Example:-

    rand_seed: 12345

## float_format

Type: str

Format string for numerical output

Example:-

    float_format: default

# DESCRIPTION

Type: dict_record

Description fields for script.

Example:-

    DESCRIPTION:
        name: pk_first_order
        title: First order absorption model with peripheral compartment
        author: J.R. Hartley
        abstract: |
            A two compartment PK model with bolus dose and
            first order absorption, similar to a nonmem advan4trans4 model.
        keywords: ['tutorial', 'pk', 'advan4', 'dep_two_cmp', 'first order']

## name

Type: str

Unique name used to distinguish script

Example:-

    name: pk_first_order

## title

Type: str

A longer text string that could serve as a title

Example:-

    title: First order absorption model with peripheral compartment

## author

Type: str

Author of the model

Example:-

    author: J.R. Hartley

## abstract

Type: verbatim

Abstract paragraph describing model

Example:-

    abstract: |
        A two compartment PK model with bolus dose and
        first order absorption, similar to a nonmem advan4trans4 model.

## keywords

Type: list

Keywords list used to categorise models.

Example:-

    keywords: ['tutorial', 'pk', 'advan4', 'dep_two_cmp', 'first order']

# FILE_PATHS

Type: dict_record

file paths

Example:-

    FILE_PATHS:
        output_folder: auto
        output_file_ext: ['svg']
        output_iteration_results: True

## output_folder

Type: output_folder / auto

Output folder - results of computation stored here

Example:-

    output_folder: auto

## output_file_ext

Type: list_of(pdf,png,svg)

Output file extension - determines graphical output file format.

Example:-

    output_file_ext: ['svg']

## output_iteration_results

Type: bool

Option to output iteration-by-iteration values.

Example:-

    output_iteration_results: True

# DATA_FIELDS

Type: dict_record

data fields for popy.dat.fields object

Example:-

    DATA_FIELDS:
        type_field: TYPE
        id_field: ID
        time_field: TIME

## type_field

Type: str

Field name in data file that contains row type info, e.g. obs/dose etc

Example:-

    type_field: TYPE

## id_field

Type: str

Field name in data file that contains identity string for each data row e.g. obs/dose etc

Example:-

    id_field: ID

## time_field

Type: str

Field name in data file that contains time or event for each data row

Example:-

    time_field: TIME

# LEVEL_PARAMS

Type: repeat_record

Level params to define hierarchical population model

Example:-

    LEVEL_PARAMS:
        GLOBAL:
            split_field: None

            split_dict: {}

            gen_params: |
                c[AMT] = 100.0
                f[KA] = 0.2
                f[CL] = 2.0
                f[V1] = 50
                f[Q] = 1.0
                f[V2] = 80
                f[KA_isv,CL_isv,V1_isv,Q_isv,V2_isv] = [
                    [0.1],
                    [0.01, 0.03],
                    [0.01, -0.01, 0.09],
                    [0.01, 0.02, 0.01, 0.07],
                    [0.01, 0.02, 0.01, 0.01, 0.05],
                ]
                f[PNOISE] = 0.15

            fit_params: |
                f[KA] ~ P1.0
                f[CL] ~ P1.0
                f[V1] ~ P20
                f[Q] ~ P0.5
                f[V2] ~ P100
                f[KA_isv,CL_isv,V1_isv,Q_isv,V2_isv] ~ spd_matrix() [
                    [0.05],
                    [0.01, 0.05],
                    [0.01, 0.01, 0.05],
                    [0.01, 0.01, 0.01, 0.05],
                    [0.01, 0.01, 0.01, 0.01, 0.05],
                ]
                f[PNOISE] ~ P0.1

        INDIV:
            split_field: ID

            split_dict: "*"

            gen_params: |
                c[ID] = sequential(50)
                t[DOSE] = 2.0
                t[OBS] ~ unif(1.0, 50.0; 5)
                # t[OBS] = range(1.0, 50.0; 5)
                r[KA, CL, V1, Q, V2] ~ mnorm([0,0,0,0,0], f[KA_isv,CL_isv,V1_isv,Q_isv,V2_isv])

            fit_params: |
                r[KA, CL, V1, Q, V2] ~ mnorm([0,0,0,0,0], f[KA_isv,CL_isv,V1_isv,Q_isv,V2_isv])

## split_field

Type: str

Field to split level into sub levels

Example:-

    split_field: none

## split_dict

Type: dict / star

Defines named subsets, defined by ranges of split field values

Example:-

    split_dict: {}

## gen_params

Type: verbatim

Defines f[X] and r[X] variables in split field ranges for gen_scripts

Example:-

    gen_params: |

## fit_params

Type: verbatim

Defines f[X] and r[X] variables in split field ranges for fit_scripts

Example:-

    fit_params: |

# MODEL_PARAMS

Type: verbatim

Defines the mapping from c[X], f[X] and r[X] variables to individual model m[X] parameters.

Example:-

    MODEL_PARAMS: |
        m[KA] = f[KA] * exp(r[KA])
        m[CL] = f[CL] * exp(r[CL])
        m[V1] = f[V1] * exp(r[V1])
        m[Q] = f[Q] * exp(r[Q])
        m[V2] = f[V2] * exp(r[V2])
        m[ANOISE] = 0.001
        m[PNOISE] = f[PNOISE]

# STATES

Type: verbatim

Optional section for setting initial values of s[X] variables can also set slabel[X] text labels.

Example:-

    STATES: |

# DERIVATIVES

Type: verbatim

Define how the covariates and effects determine flows between compartments.

Example:-

    DERIVATIVES: |
        # s[DEPOT,CENTRAL,PERI] = @dep_two_cmp_cl{dose:@bolus{amt:c[AMT]}}
        d[DEPOT] = @bolus{amt:c[AMT]} - m[KA]*s[DEPOT]
        d[CENTRAL] = m[KA]*s[DEPOT] - s[CENTRAL]*m[CL]/m[V1] - s[CENTRAL]*m[Q]/m[V1]  + s[PERI]*m[Q]/m[V2]
        d[PERI] = s[CENTRAL]*m[Q]/m[V1] - s[PERI]*m[Q]/m[V2]

# PREDICTIONS

Type: verbatim

Define the final predicted m[X] variables to be output by the compartment model system.

Example:-

    PREDICTIONS: |
        p[DV_CENTRAL] = s[CENTRAL]/m[V1]
        var = m[ANOISE]**2 + m[PNOISE]**2 * p[DV_CENTRAL]**2
        c[DV_CENTRAL] ~ norm(p[DV_CENTRAL], var)

# ODE_SOLVER

Type: one_of_record

one of many possible solvers

Example:-

    ODE_SOLVER:
        SCIPY_ODEINT: {atol: 1e-06, rtol: 1e-06, max_nsteps: 10000000, use_sens: False}

## NO_SOLVER

Type: dict_record

Null method for blank derivatives.

Example:-

    NO_SOLVER: {}

## ANALYTIC

Type: dict_record

Analytic method for solving ODE

Example:-

    ANALYTIC: {}

## SCIPY_ODEINT

Type: dict_record

odeint solver record

Example:-

    SCIPY_ODEINT:
        atol: 1e-06
        rtol: 1e-06
        max_nsteps: 10000000
        use_sens: False

### atol

Type: float

Absolute tolerance of ode solver.

Example:-

    atol: 1e-06

### rtol

Type: float

Relative tolerance of ode solver.

Example:-

    rtol: 1e-06

### max_nsteps

Type: int

Maximum number of steps allowed in ode solver.

Example:-

    max_nsteps: 10000000

### use_sens

Type: bool

Option to use sensitivity equations in ode solver.

Example:-

    use_sens: False

# FIT_METHODS

Type: list_record

one of many possible fitters

Example:-

    FIT_METHODS:
        - JOE:
            ODE_SOLVER: {INHERIT: {}}
            max_n_main_iterations: 30
            CONVERGER: {OBJ_INC: {}}
            recompute_jacobians_flag: False
            use_chain: False
            reset_re_flag: True

## JOE

Type: dict_record

Joint Optimisation and Estimation method

Example:-

    JOE:
        ODE_SOLVER: {INHERIT: {}}
        max_n_main_iterations: 50
        CONVERGER: {OBJ_INC: {}}
        recompute_jacobians_flag: False
        use_chain: False
        reset_re_flag: True

### max_n_main_iterations

Type: int

Maximum number of iterations

Example:-

    max_n_main_iterations: 50

### CONVERGER

Type: one_of_record

Convergence methods.

Example:-

    CONVERGER:
        OBJ_INC: {}

#### NONE

Type: dict_record

No convergence testing.

Example:-

    NONE: {}

#### OBJ_INC

Type: dict_record

Objective function increase converger.

Example:-

    OBJ_INC: {}

#### OBJ_SIM

Type: dict_record

Objective function similar converger.

Example:-

    OBJ_SIM: {}

### recompute_jacobians_flag

Type: bool

Option to recompute jacobians more often, e.g in noise optimiser.

Example:-

    recompute_jacobians_flag: False

### use_chain

Type: bool

Option to use chain rule when computing derivatives.

Example:-

    use_chain: False

### reset_re_flag

Type: bool

Reset r[X]=0.0 before each r[X] optimisation

Example:-

    reset_re_flag: True

# COVARIANCE

Type: one_of(none,default,nonmem)

Method for computing standard errors

Example:-

    COVARIANCE: none

# OUTPUT_SCRIPTS

Type: dict_record

scripts to output for further processing

Example:-

    OUTPUT_SCRIPTS:
        GEN: {output_mode: gen_script_and_run, sim_time_step: 1.0, share_axes: True}
        FIT: {output_mode: gen_script_and_run, sim_time_step: 1.0, share_axes: True}
        COMP: {output_mode: gen_script_and_run}
        TUTSUM: {output_mode: gen_script_and_run}

## GEN

Type: dict_record

options to pass to gen script.

Example:-

    GEN:
        output_mode: no_output
        sim_time_step: -1.0
        share_axes: False

### output_mode

Type: one_of(no_output,gen_script_only,gen_script_and_run)

Output options.

Example:-

    output_mode: no_output

### sim_time_step

Type: float

Size of time step when creating smooth curve predictions note setting this to a negative value, results in simulated predictions for each individual ONLY at time points in the original data set.

Example:-

    sim_time_step: -1.0

### share_axes

Type: bool

Option to share axes between individuals when plotting graphical data

Example:-

    share_axes: False

## FIT

Type: dict_record

options to pass to fit script.

Example:-

    FIT:
        output_mode: no_output
        sim_time_step: -1.0
        share_axes: False

### output_mode

Type: one_of(no_output,gen_script_only,gen_script_and_run)

Output options.

Example:-

    output_mode: no_output

### sim_time_step

Type: float

Size of time step when creating smooth curve predictions note setting this to a negative value, results in simulated predictions for each individual ONLY at time points in the original data set.

Example:-

    sim_time_step: -1.0

### share_axes

Type: bool

Option to share axes between individuals when plotting graphical data

Example:-

    share_axes: False

## COMP

Type: dict_record

options to pass to comp script.

Example:-

    COMP:
        output_mode: no_output

### output_mode

Type: one_of(no_output,gen_script_only,gen_script_and_run)

Output options.

Example:-

    output_mode: no_output

## TUTSUM

Type: dict_record

options to pass to tutsum script.

Example:-

    TUTSUM:
        output_mode: no_output

### output_mode

Type: one_of(no_output,gen_script_only,gen_script_and_run)

Output options.

Example:-

    output_mode: no_output