Code blocks and user code

Custom text expressions, equations, and PML code can be included in Phoenix models by using code blocks in the graphical model editor, or by entering model code in the Model panel when using the Phoenix model in text model mode. All custom code is referred to as user code.

Many model blocks allow users to add custom text expressions and statements to the drug model. Note that a distinction is made between an expression, which is a numeric value expressed in alge­braic terms, and a statement, which is a complete equation or action and can include an assignment operator, “=”.

Expression blocks 

The Expression block represents one variable, whose value is set by a text expression inside the block.

Procedure blocks 

Use a procedure block to enter assignment statements and differential equations, and to create new structural parameters. These statements are inserted in the model, alongside automatically generated statements. For example, users can define new structural parameters Q and R, and then enter this code written in the block:

    deriv(B=-B*Q)
    D=B/R

It is important not to write code that depends on time “t” or other continuously changing variables to equal exact values, such as:

    x=((t==4)?xxx:yyy)

because this code is executed very frequently, including every time a derivative evaluation is per­formed. Time “t” takes on many values, along with other continuously changing variables, but cannot be relied on to equal any particular value, or even to advance monotonically. However, covariates, if not interpolated, use the specific values that they are set to by the input data.

Also, it is not a good idea to write code containing discontinuities, such as

   x=((t>=4)?xxx:yyy)

because x discontinuously changes from xxx to yyy at time 4. Assuming x enters the model in some way, it can either cause the ODE solver or the modeling engine to be faced with a discontinuity. If the ODE solver encounters a discontinuity, it responds by adjusting the step size to as small a value as possible in order to minimize error, which can greatly slow model performance. If the modeling engine encounters a discontinuity, it responds by trying (and failing) to make a continuous model in the region of the discontinuity, resulting in a troublesome fit and possible lack of standard errors. Use the sequence statement in the PML to schedule events when discrete actions can be taken.

Syntax for text expressions and statements

General syntax information

Expression syntax

An expression represents a single numerical quantity in algebraic terms. It does not contain an assignment, or “=”.

An expression may include any combination of the following:

Statement syntax

Statements can follow each other on a single line or be set on different lines.

    statement statement …

The most common type of statement is an assignment, for example:

    x=5+y;

This statement assigns the variable x the value 5+y. Note that x and y must be valid drug model vari­ables. The semicolon character (;) separating statements is optional.

Differential equations can be created only by using deriv statements inside a Procedure block. Note that the variable t, the time variable, can be used inside of a deriv statement. t represents subject time, which is the elapsed time since the first event experienced by the subject.

For available logical operators and functions that can be used in statements, see “Supported Opera­tors”, “Supported Math Functions”, and “Supported Special Functions”.

Pooled data

The NLME engine used by the Phoenix Model Object can be used for analyzing pooled data. This approach fits one set of model parameters to all individuals in a dataset. There are some require­ments that must be met to properly configure a pooled model:

Make sure that the data are sorted by individual then by time, so that all the observations for any individual are in consecutive and ascending time order. Then clear the Sort Input? checkbox on the Run Options tab.

Select the Reset? checkbox in the Input Options tab and include a column with an indicator for the initial time.

Dosing information must be placed in the observation data. The Dosing Panel does not func­tion properly for Pooled data.

 


Last modified date:6/26/19
Certara USA, Inc.
Legal Notice | Contact Certara
© 2019 Certara USA, Inc. All rights reserved.