NONMEM Users Network Archive

Hosted by Cognigen

Re: RES and WRES output with Beal's M3 method

From: Sebastien Bihorel <Sebastien.Bihorel>
Date: Wed, 07 Apr 2010 13:57:06 -0400

Hi Martin,

Thanks for your reply. I tend to agree with you this should be
considered as a bug.

I tried different options to access to the actual RES and WRES inside
the $ERROR block. The best I could do so far was to access to PRED
values using (COMACT.EQ.1). With this call, I can assign PRED values to
a PPRED variable that I used to compute some residuals PRES (DV-PPRED)
and some weighted residuals PWRES (RES/W) using your defining of W. This
provides some non-zero values for non-BLOQ samples. By checking PRES and
PWRES against RES and WRES for patients without BLOQ samples, it appears
that PWRES is correct as long as I don't include inter-individual
variability in my model (PRES seems to be always correct).

Any idea how the formula for PWRES should be altered?


New code:


;Information needed for BLQF and > BLQF samples

DFLG=0 ;create a dose record flag


;Computations for samples with DV > LOQ (BLQF=0)
 Y=IPRED+W*SIG*EPS(1) ;NOTE: Prediction is a concentration

;Computations for samples with DV <= LOQ (BLQF=1)
 Y=IPRED ;NOTE: prediction is a *probability*

Martin Bergstrand wrote:
> Dear Sebastien and NONMEM users,
> It is correct that NONMEM doesn't return any RES or WRES for individuals who
> have at least one observation with F_FLAG=1. It is understandable that
> NONMEM can't return residuals for the BQL observations (F_FLAG=1) since PRED
> is a likelihood in this case and not a prediction (furthermore the
> observation is an interval and can neither be used to calculate a residual).
> However, I don't understand why it doesn't do so for the observations for
> which F_FLAG=0? Can this be considered a bug?
> You can of course always get out individual residuals (IRES) and individual
> weighted residuals (IWRES) (below this paragraph you can see my definition
> of IWRES). What you can do if you really want to get RES and WRES is to run
> a MAXEVAL=0 run with your final estimates. The BQL data should in this case
> be omitted (or set to a fix value) and all M3 code taken out. Remember in
> this case that the IRES and IWRES and other EBE dependent variables will not
> be correct following the MAXEVAL=0 run (i.e. use only the PRED, RES and WRES
> out of this run and the rest from your original fit with the M3 code). In
> case you are using the FOCE estimation method you would preferably want to
> look at conditional weighted residuals (CWRES) rather than WRES. However I
> have yet not seen any example of a workaround to get these when using the M3
> method (Obs! CWRES will not be correctly calculated with the MAXEVAL=0
> trick).
> W = THETA(11) ; SD for additive
> residual error
> ; W = THETA(11) * IPRED ; SD for proportional
> residual error
> ; W = SQRT(THEATA(11)**2+THETA(12)**2*IPRED**2) ; SD for combined
> residual error
> Y = IPRED + W*EPS(1)
> If you use Xpose to do your diagnostic plots it can be good to know that
> Xpose by default omits all rows with WRES=0 (this is done to omit
> information on dosing row from being plotted). You can change this setting
> in Xpose by using the command inclZeroWRES=TRUE (you should then enter some
> other subset to omit the dose rows e.g. subset="EVID==0").
> My favorite type of diagnostics are VPCs (I think I share this with Prof.
> Nick Holford). VPCs can easily be adopted to handle the presence of BQL
> data. How to do this with PsN and Xpose is explained in a PAGE poster from
> 2009
> (
> f).
> Best regards,
> Martin Bergstrand, MSc, PhD student
> -----------------------------------------------
> Pharmacometrics Research Group,
> Department of Pharmaceutical Biosciences,
> Uppsala University
> -----------------------------------------------
> martin.bergstrand
> -----------------------------------------------
> Work: +46 18 471 4639
> Mobile: +46 709 994 396
> Fax: +46 18 471 4003
> -----Original Message-----
> From: owner-nmusers
> Behalf Of Sebastien Bihorel
> Sent: den 7 april 2010 17:31
> To: nmusers
> Subject: [NMusers] RES and WRES output with Beal's M3 method
> Dear NONMEM users,
> We have noticed some problems with the table outputs of RES and WRES,
> when we implemented Beal's M3 method as proposed by Ahn and colleagues
> (J Pharmacokinet Pharmacodyn (2008) 35:401-421). While RES and WRES are
> correctly calculated and reported for patients without BLOQ records,
> these metrics are reported as being 0 for patients with at least one
> BLOQ sample, even for the records that were not flagged as BLOQ. This
> behavior seems to be common to NONMEM 6 and 7.
> Does anybody know about an NONMEM option or a workaround that would
> allow the user to access to the actual RES and WRES for the non-BLQ records?
> Any feedback would be greatly appreciated.
> Sebastien Bihorel
> PS: this is the $ERROR block code we used for a simple proportional RV model
> ;Information needed for BLQF and > BLQF samples
> LOQ=5
> SIG = THETA(3)
> DFLG=0 ;create a dose record flag
> ;Computations for samples with DV > LOQ (BLQF=0)
> IF (BLQF.LT.0.25) THEN
> F_FLAG=0
> FFLG=0
> Y=IPRED+W*SIG*EPS(1) ;NOTE: Prediction is a concentration
> ;Computations for samples with DV <= LOQ (BLQF=1)
> IF (BLQF.GE.0.25) THEN
> F_FLAG=1
> FFLG=1
> Y=IPRED ;NOTE: prediction is a *probability*
Received on Wed Apr 07 2010 - 13:57:06 EDT

The NONMEM Users Network is maintained by ICON plc. Requests to subscribe to the network should be sent to:

Once subscribed, you may contribute to the discussion by emailing: