compute.cwres {MIfuns}R Documentation

Compute the Conditional Weighted Residuals

Description

This function computes the conditional weighted residuals (CWRES) from a NONMEM run. CWRES are an extension of the weighted residuals (WRES), but are calculated based on the first-order with conditional estimation (FOCE) method of linearizing a pharmacometric model (WRES are calculated based on the first-order (FO) method). The function requires a NONMEM table file and an extra output file that must be explicitly asked for when running NONMEM, see details below.

Usage

compute.cwres(run.number,
              tab.prefix="cwtab",
              sim.suffix="",
              est.tab.suffix=".est",
              deriv.tab.suffix=".deriv",
              old.file.convention=FALSE,
              id="ALL",
              printToOutfile=TRUE,
              onlyNonZero=TRUE,
              ...)

Arguments

run.number The run number of the NONMEM from which the CWRES are to be calculated.
tab.prefix The prefix to two NONMEM file containing the needed values for the computation of the CWRES, described in the details section.
sim.suffix The suffix ,before the ".", of the NONMEM file containing the needed values for the computation of the CWRES, described in the details section. For example, the table files might be named cwtab1sim.est and cwtab1sim.deriv, in which case sim.suffix="sim".
est.tab.suffix The suffix, after the ".", of the NONMEM file containing the estimated parameter values needed for the CWRES calculation.
deriv.tab.suffix The suffix, after the ".", of the NONMEM file containing the derivatives of the model with respect to the random parameters needed for the CWRES calculation.
old.file.convention For backwards compatibility. Use this if you are using the previous file convention for CWRES (table files named cwtab1, cwtab1.50, cwtab1.51, ... , cwtab.58 for example).
id Can be either "ALL" or a number matching an ID label in the datasetname.
printToOutfile Logical (TRUE/FALSE) indicating whether the CWRES values calculated should be appended to a copy of the datasetname. Only works if id="ALL". If chosen the resulting output file will be datasetname.cwres.
onlyNonZero Logical (TRUE/FALSE) indicating if the return value (the CWRES values) of compute.cwres should include the zero values associated with non-measurement lines in a NONMEM data file.
tab.suffix The suffix to the NONMEM table file containing the derivative of the model with respect to the etas and epsilons, described in the details section.
... Other arguments passed to basic functions in code.

Details

compute.cwres
This function is the computational 'brains' of the CWRES computation. The function simply reads in the following two files:

      paste(tab.prefix,run.number,sim.suffix,est.tab.suffix,sep="")
      paste(tab.prefix,run.number,sim.suffix,deriv.tab.suffix,sep="")

Which might be for example:

      cwtab1.est
      cwtab1.deriv

and (depending on the input values to the function) returns the CWRES in vector form as well as creating a new table file named:

      paste(tab.prefix,run.number,sim.suffix,sep="")

Which might be for example:

      cwtab1

Value

compute.cwres Returns a vector containing the values of the CWRES.

Setting up the NONMEM model file

In order for this function to calculate the CWRES, NONMEM must be run while requesting certain tables and files to be created. How these files are created differs depending on if you are using $PRED or ADVAN as well as the version of NONMEM you are using. These procedures are known to work for NONMEM VI but may be different for NONMEM V. We have attempted to indicate where NONMEM V may be different, but this has not been extensively tested!

There are five main insertions needed in your NONMEM control file:

    1. $ABB COMRES=X.

    Insert this line directly after your $DATA line. The value of X is the number of ETA() terms plus the number of EPS() terms in your model. For example for a model with three ETA() terms and two EPS() terms the code would look like this:

           $DATA temp.csv IGNORE=@
           $ABB COMRES=5
           $INPUT ID TIME DV MDV AMT EVID
           $SUB ADVAN2 TRANS2
    

    2. Verbatim code.

    3. INFN routine.

    4. cwtab*.deriv table file.

    A special table file needs to be created to print out the values contained in the COMRES variables. In addition the ID, IPRED, MDV, DV, PRED and RES data items are needed for the computation of the CWRES. The following code should be added to the NONMEM model file. In this example we continue to assume that we are using a model with three ETA() terms and two EPS() terms, extra terms should be added for new ETA() and EPS() terms in the model file.

           $TABLE ID COM(1)=G11 COM(2)=G21 COM(3)=G31
           COM(4)=H11 COM(5)=H21 
           IPRED MDV NOPRINT ONEHEADER FILE=cwtab1.deriv
    

    5. $ESTIMATION.

    To compute the CWRES, the NONMEM model file must use (at least) the FO method with the POSTHOC step. If the FO method is used and the POSTHOC step is not included then the CWRES values will be equivalent to the WRES. The CWRES calculations are based on the FOCE approximation, and consequently give an idea of the ability of the FOCE method to fit the model to the data. If you are using another method of parameter estimation (e.g. FOCE with interaction), the CWRES will not be calculated based on the same model linearization procedure.

Author(s)

Andrew Hooker

References

Hooker A, Staatz CE, Karlsson MO. Conditional weighted residuals, an improved model diagnostic for the FO/FOCE methods. PAGE 15 (2006) Abstr 1001 [http://www.page-meeting.org/?abstract=1001].

See Also

CWRES,compute.cwres


[Package MIfuns version 3.2.9 Index]