81  $THETAI ($THI) AND $THETAR ($THR) Records for Transforming Initial THETAs and Reporting THETAs (NM73)

Introduction to NONMEM 7.6.0

Author

Robert J. Bauer

Published

June 1, 2025

Initial THETAs in the $THETA record may be functionally transformed with the $THETAI (or $THI) record, and final THETAs may then be reverse transformed for report purposes using $THETAR (or $THR). This has particular value when it is desired that the THETAs by estimated within NONMEM in the log domain, but you want the convenience of inputting and outputting them in the natural domain, such as when performing linear MU referencing. For example,

$THETAI
THETA(1:NTHETA)=LOG(THETAI(1:NTHETA))
THETA(NTHETA+1:NTHETA+NTHP)=LOG(THETAI(NTHETA+1:NTHETA+NTHP))

Or

$THETAI
THETA(1:NTHETA)=LOG(THETAI(1:NTHETA))
THETAP(1:NTHP)=LOG(THETAPI(1:NTHP))

Where ntheta=number of to be estimated THETAs, and nthp=number of theta priors. Or, leave it to NONMEM to supply the range (which is by default NTHETA+NTHP).

$THETAI
THETA=LOG(THETAI)

This record will convert any initial THETAs in a $THETA record, or THETAs obtained from a chain file, but will not convert THETAs from an MSF file. Furthermore, the variance to the theta priors will be appropriately converted, when using $PRIOR NWPRI ($PRIOR TNPRI receives variance-covariance information from MSF files, and this information is in the model theta domain).

For reporting THETAs, the inverse function should be supplied:

$THETAR
THETAR=EXP(THETA)

Or

$THETAR
THETAR(1:NTHETA)=EXP(THETA(1:NTHETA))
THETAPR(1:NTHP)=EXP(THETAP(1:NTHP))

The code in $THETAI and $THETAR is transferred to the FORTRAN compiler without interpretation.

An example is shown with thetair.ctl:

$PROB RUN# From Example 1
$INPUT C SET ID JID TIME DV=CONC AMT=DOSE RATE EVID MDV CMT
$DATA example1.csv IGNORE=C

$SUBROUTINES ADVAN3 TRANS4

$THI
THETA(1:NTHETA)=DLOG(THETAI(1:NTHETA))
THETAP(1:NTHP)=DLOG(THETAPI(1:NTHP))

$THR
THETAR(1:NTHETA)=DEXP(THETA(1:NTHETA))
THETAPR(1:NTHP)=DEXP(THETAP(1:NTHP))

$PK
MU_1=THETA(1)
MU_2=THETA(2)
MU_3=THETA(3)
MU_4=THETA(4)
CL=DEXP(MU_1+ETA(1))
V1=DEXP(MU_2+ETA(2))
Q=DEXP(MU_3+ETA(3))
V2=DEXP(MU_4+ETA(4))
S1=V1

$ERROR
Y = F + F*EPS(1)

; Initial values of THETA
$THETA (7.389056099)X4
;INITIAL values of OMEGA
$OMEGA BLOCK(4) VALUES(0.2,0.001)
;Initial value of SIGMA
$SIGMA
(0.6 ) ;[P]

$PRIOR NWPRI
;prior information on THETAs
$THETAP (7.389056099 FIX)X4
;variance to theta priors
$THETAPV BLOCK(4) FIX VALUES(545981.5003,0.0)

; Prior information to the OMEGAS.
$OMEGAP BLOCK(4)
0.2 FIX
0.0 0.2
0.0 0.0 0.2
0.0 0.0 0.0 0.2
$OMEGAPD (4 FIX)

$EST METHOD=ITS INTERACTION NOABORT CTYPE=3 PRINT=5 NOPRIOR=1
$EST METHOD=BAYES INTERACTION NOABORT NBURN=200 NITER=500 CTYPE=3
PRINT=50 NOPRIOR=0
$EST METHOD=1 INTERACTION NSIG=3 SIGL=10 PRINT=1 NOABORT
MAXEVAL=9999 NOPRIOR=1
$COV MATRIX=R PRINT=E UNCONDITIONAL

Note the use of informative names for the prior information (see I.43 A Note on Setting up Prior Information).

When using $THETAI, be aware that the any bounds described in the $THETA record are also submitted to the $THETAI transformations. Therefore, bounds that are likely to cause a domain error in the transformation process should not be included. For example, When Theta is log transformed, the lower bound of 0 should not be included. The transformation itself will prevent reported THETAs from being less than 0.

$THI
THETA(1)=LOG(THETAI(1))

$THETA
(0,5.0) ; not good

…
$THETA
(0.1,5.0) ; okay.

…
$THETA
5.0 ; okay.