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

**URL:** https://discourse.pumas.ai/t/how-to-define-distribution-of-the-residual-deviates-eps-in-pumas/526
**Category:** How-to
**Created:** [September 30, 2021, 1:20am UTC](https://discourse.pumas.ai/t/how-to-define-distribution-of-the-residual-deviates-eps-in-pumas/526 "2021-09-30T01:20:18Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![pawangpt700](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/pawangpt700/32/387_2.png) [@pawangpt700](https://discourse.pumas.ai/u/pawangpt700)
#### Post date: [September 30, 2021, 1:20am UTC](https://discourse.pumas.ai/t/how-to-define-distribution-of-the-residual-deviates-eps-in-pumas/526/1 "2021-09-30T01:20:18Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![benjaminrich](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/benjaminrich/32/156_2.png) [@benjaminrich](https://discourse.pumas.ai/u/benjaminrich)
#### Post date: [September 30, 2021, 2:08am UTC](https://discourse.pumas.ai/t/how-to-define-distribution-of-the-residual-deviates-eps-in-pumas/526/2 "2021-09-30T02:08:39Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![pawangpt700](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/pawangpt700/32/387_2.png) [@pawangpt700](https://discourse.pumas.ai/u/pawangpt700)
#### Post date: [September 30, 2021, 3:08am UTC](https://discourse.pumas.ai/t/how-to-define-distribution-of-the-residual-deviates-eps-in-pumas/526/3 "2021-09-30T03:08:17Z")

</div>

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(ERR0 **2+ERR1** 2_IPRED_IPRED)  
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

---

<div class="post-metadata">

### Author: ![benjaminrich](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/benjaminrich/32/156_2.png) [@benjaminrich](https://discourse.pumas.ai/u/benjaminrich)
#### Post date: [September 30, 2021, 12:03pm UTC](https://discourse.pumas.ai/t/how-to-define-distribution-of-the-residual-deviates-eps-in-pumas/526/4 "2021-09-30T12:03:54Z")

</div>

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:

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

```

Does that make sense?

---

<div class="post-metadata">

### Author: ![pawangpt700](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/pawangpt700/32/387_2.png) [@pawangpt700](https://discourse.pumas.ai/u/pawangpt700)
#### Post date: [September 30, 2021, 2:19pm UTC](https://discourse.pumas.ai/t/how-to-define-distribution-of-the-residual-deviates-eps-in-pumas/526/5 "2021-09-30T14:19:57Z")

</div>

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

---

<div class="post-metadata">

### Author: ![andreasnoack](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/andreasnoack/32/22_2.png) [@andreasnoack](https://discourse.pumas.ai/u/andreasnoack)
#### Post date: [October 4, 2021, 8:30pm UTC](https://discourse.pumas.ai/t/how-to-define-distribution-of-the-residual-deviates-eps-in-pumas/526/6 "2021-10-04T20:30:07Z")

</div>

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

```auto
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)

---

<div class="post-metadata">

### Author: ![pawangpt700](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/pawangpt700/32/387_2.png) [@pawangpt700](https://discourse.pumas.ai/u/pawangpt700)
#### Post date: [October 7, 2021, 8:02pm UTC](https://discourse.pumas.ai/t/how-to-define-distribution-of-the-residual-deviates-eps-in-pumas/526/7 "2021-10-07T20:02:37Z")

</div>

Thank you, @andreasnoack!
