Recreating NONMEM Model

I am trying to create the Brooks model for Fludarabine in Pediatric Population as I want to run multiple simulations to generate data. But the $ERROR part in the NONMEM code is little bit confusing for me, can someone explain how I can recreate it in Julia.

$ERROR
ITMP = 1 ; different error for V1 (central) and V3 (intracellular)
IF(CMT.EQ.3) ITMP = 0 
W1      = THETA(9)
IF(W1.EQ.0) W1=1
W2      = THETA(10) 
; LTBS
FLG = 0
IF(AMT.NE.0) FLG=0.000001
IPRED = F
Y = LOG(IPRED + FLG) + W1*EPS(1)*ITMP + W2*EPS(2)*(1-ITMP)
AUC = A(4)

Are you looking for something like this?

@derived begin
    cp = @. Central/Vc
    int_cp = @. Intracellular/Vint
    log_dv ~ @. Normal(log(abs(cp)), σ_dv)
    log_int_dv ~ @. Normal(log(abs(int_cp)), σ_dv_int)
end
1 Like

Hi @vijay thank you for your reply, why have they used a log? I understand they have used absolute value to keep the concentration values non-negative. But what is the reason they could be using log