[Solved] Cannot identify the cause for this 'F or derivative is INF or NAN' error

Dear all,

I am fitting a ADVAN3 TRANS4 model with M3 method. The base model (MODEL_001) consists of single parameter estimates for each PK parameter and its distribution, proportional+additive residual error model and effect of BSA on V1. The only difference of MODEL_002 is that the additive component of the RUV is removed, by fixed SGM_PROP and EPS_PROP to zero.

But when fitting MODEL_002, the following error occurs at the first observation of the first subject (i.e. ID=1, rec 2), which does not happen for MODEL_001

OCCURS DURING SEARCH FOR ETA AT INITIAL VALUE, ETA=0
F OR DERIVATIVE RETURNED BY PRED IS INFINITE (INF) OR NOT A NUMBER (NAN).

So far I cannot identify the cause of the issue. ID=1, rec 2 has a DV above LLOQ so the likelihood should be computed based on the DV and the error size (i.e. F_FLAG = 0). I have checked the syntax a few times and it seems to be irrelevant.

Please find a reproducible example in the link below. Any help is appreciated!

====================================================

SOLVED:
So, the problem is due to the dosing record, which has IPRED=0, being put at the denominator during evaluation. I tried to bypass this problem this way, which seems to be helpful at this point:

IF (F.EQ.0) CUMD=1
IF (F.GT.0) CUMD=PHI((LOQ-F)/SD)
IF (DV.GE.LOQ) THEN
F_FLAG=0
Y=F+ERR_PROP+ERR_ADD
ELSE
F_FLAG=1
Y=CUMD
ENDIF

3 Likes

Hi @matthew_hkh,

One other note on your model: As you’re assigning SD in the $ERROR, you should not immediately assign EPS(1) and EPS(2) to ERR_PROP and ERR_ADD. With your code as given:

ERR_PROP=SGM_PROP*EPS(1)
ERR_ADD=SGM_ADD*EPS(2)
SD=SQRT((F*SGM_PROP)**2+SGM_ADD**2)
IF (DV.GE.LLOQ) THEN
	F_FLAG=0
	Y=F*(1+ERR_PROP)+ERR_ADD

	FLAG=0
ELSE
	F_FLAG=1
	Y=PHI((LLOQ-F)/SD)
	FLAG=1
ENDIF

You’ll calculate your SD with random variation and your Y in the ELSE block will be random. You’d want to do the following (also including your fix from your message above) and you no longer need EPS(2).

ERR_PROP=SGM_PROP
ERR_ADD=SGM_ADD
SD=SQRT((F*SGM_PROP)**2+SGM_ADD**2)
IF (F.EQ.0) CUMD=1
IF (F.GT.0) CUMD=PHI((LOQ-F)/SD)
IF (DV.GE.LLOQ) THEN
	F_FLAG=0
	Y=F+SD*EPS(1)
	FLAG=0
ELSE
	F_FLAG=1
	Y=CUMD
	FLAG=1
ENDIF

Really what was happening in my case was that SD was going zero.
Solved it by:
DEL=1.0E-30
; ------------------------------------------------
SD = THETA(7) ; prop error
IF (SIG.LE.0) SD = DEL