# How to define distribution of the residual deviates (EPS) in Pumas

In NONMEM, the entries in the SIGMA block represent the initial values of variances and covariances for the residual deviates (EPS). I am wondering if there is a specific way to do the same in Pumas for the mixed error models.

Sure. But can you be a bit more specific about your model? Can you post a code example? That would make it easier to give you clear advice.

For example, I am trying to convert the following NONMEM mixed error model to Pumas (in the model just before the estimation block towards the end SIGMA is fixed to 1):

$SUBROUTINE ADVAN2 TRANS2$INPUT STUDY ID TIME AMT DV AGE SEX HEIGHT WEIGHT BMI RACE CYCLE
DAY ALT ALB AST BILI SCR CRCL GENOTYPE SEQUENCE ISFED OCC
EVID MDV FBQL CMT

$DATA …/data/test_data.csv IGNORE=@$PK
TVCL = THETA(1)
TVV = THETA(2)
TVKA = THETA(3)

CL = TVCL * EXP(ETA(1))
V = TVV * EXP(ETA(2))
KA = TVKA * EXP(ETA(3))
S1 = V
$ERROR IPRED=F ERR0=THETA(4) ERR1=THETA(5) W = SQRT(ERR02+ERR12IPREDIPRED) IRES = DV-IPRED IWRES = IRES/W Y = IPRED + W * EPS(1) **$THETA
(0, 3.94,25) ;CL
(0, 2.76,20) ;V
(0, 3.11) ;ka
(0.0001, 0.12) ;Err0
(0.0001, 0.105) ;Err 1

$OMEGA 0.0225 ;CL 0.0157 ;V 0.107 FIX ;ka$SIGMA 1 FIX

$ESTIMATION MAX=9000 NOABORT PRINT=1 MET=1 INTER SIG=2 SADDLE_RESET=1 SADDLE_HESS=1$COVAR PRECOND=4
\$TABLE ID TIME IWRES CWRES IPRED DV MDV CWRES DOSE ABSO BI EC GA S1 KEL
NOPRINT FILE=sdtab1

Actually, this is so much simpler in Pumas than in NONMEM. Note that unlike NONMEM, Pumas does not distinguish between THETA, OMEGA and SIGMA; they are all just parameters. You don’t need to create a dummy parameter that is fixed to 1. You just write the expression in the natural way, something like:

@derived begin
dv ~ @. Normal(ipred, w)
end


Does that make sense?

Yes, it is clear now. thank you, @benjaminrich!

In case you want the two error components to be correlated then you can do so by introducing a covariance parameter and then write the error model as

y ~ @. Normal(μ, sqrt((μ*σₚ)^2 + σₐ^2 + 2*μ*σₚₐ))


where σₚₐ is the covariance parameter. It comes from the fact that

\mathrm{Var}(y) = \mathrm{Var}(\mu*\varepsilon_p + \varepsilon_a) = \mu^2\mathrm{Var}(\varepsilon_p) + \mathrm{Var}(\varepsilon_a) + 2\mathrm{Cov}(\varepsilon_p, \varepsilon_a)

Thank you, @andreasnoack!