# Issue with PK02 exercise "simobs"

**URL:** <https://discourse.pumas.ai/t/issue-with-pk02-exercise-simobs/447>\
**Category:** Uncategorized\
**Created:** [December 7, 2020, 5:50pm UTC](https://discourse.pumas.ai/t/issue-with-pk02-exercise-simobs/447 "2020-12-07T17:50:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![CPeer](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/cpeer/32/146_2.png) [@CPeer](https://discourse.pumas.ai/u/CPeer)\
**Post date:** [December 7, 2020, 5:50pm UTC](https://discourse.pumas.ai/t/issue-with-pk02-exercise-simobs/447/1 "2020-12-07T17:50:57Z")

</div>

On the tutorials page (tutorials.pumas.ai), in the “Table of Contents” link, it takes you to 53 different PK exercises. On PK2, i’m getting an error when performing the simulation, specifically this code:  
Random.seed!(123)  
sim\_sub1 = simobs(pk\_02,sub1,param1,obstimes=0:1:400)  
df1 = DataFrame(sim\_sub1);

the error looks like this:

 ![Screen Shot 2020-12-07 at 12.50.32 PM](https://canada1.discourse-cdn.com/flex030/uploads/pumas/original/1X/9887aa8fde3346288d227c39d73d82ad61ad053c.png)

---

<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:** [December 7, 2020, 8:02pm UTC](https://discourse.pumas.ai/t/issue-with-pk02-exercise-simobs/447/2 "2020-12-07T20:02:38Z")

</div>

That looks odd. Could you share your complete code? Is it possible that you’ve made a copy/paste error?

---

<div class="post-metadata">

**Author:** ![CPeer](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/cpeer/32/146_2.png) [@CPeer](https://discourse.pumas.ai/u/CPeer)\
**Post date:** [December 7, 2020, 8:14pm UTC](https://discourse.pumas.ai/t/issue-with-pk02-exercise-simobs/447/3 "2020-12-07T20:14:39Z")

</div>

i typed manually, copying from the tutorial page. trying to more quickly learn syntax by manually typing it out long form. here it is:

using Pumas  
using Plots  
using CSV  
using StatsPlots  
using Random

pk\_02 = @model begin  
@param begin  
tvka ∈ RealDomain(lower=0)  
tvkel ∈ RealDomain(lower=0)  
tvvc ∈ RealDomain(lower=0)  
tvlag ∈ RealDomain(lower=0)  
Ω ∈ PDiagDomain(4)  
σ²\_prop ∈ RealDomain(lower=0)  
end

```
@random begin
    η ~ MvNormal(Ω)
end

@pre begin
    Ka = tvka * exp(η[1])
    Kel = tvkel * exp(η[2])
    Vc = tvvc * exp(η[3])
    lags = (Depot=tvlag * exp(η[4]),)
end

@dynamics begin
    Depot' = -Ka * Depot
    Central' = Ka*Depot - Kel*Central
end

@derived begin
    cp = @. Central/vcov
    dv ~ @. Normal(cp, sqrt(cp^2 * σ²_prop))
end

```

end

param1 = (tvka = 0.013,  
tvkel = 0.013,  
tvvc = 32,  
tvlag = 0,  
Ω = Diagonal([0.0, 0.0, 0.0, 0.0]),  
σ²\_prop = 0.015)

param2 = (tvka = 0.043,  
tvkel = 0.0088,  
tvvc = 32,  
tvlag = 16,  
Ω = Diagonal([0.0, 0.0, 0.0, 0.0]),  
σ²\_prop = 0.015)

ev1 = DosageRegimen(100,time=0,cmt=1)  
sub1 = Subject(id=1, events=ev1)

### Simulations with 1 cmt model

## Without lag Time

Random.seed!(123)  
sim\_sub1 = simobs(pk\_02, sub1, param1, obstimes=0:1:400)  
df1 = DataFrame(sim\_sub1);

---

<div class="post-metadata">

**Author:** ![CPeer](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/cpeer/32/146_2.png) [@CPeer](https://discourse.pumas.ai/u/CPeer)\
**Post date:** [December 7, 2020, 8:33pm UTC](https://discourse.pumas.ai/t/issue-with-pk02-exercise-simobs/447/4 "2020-12-07T20:33:39Z")

</div>

I found the error… in the model, under “@derived” when i defined cp, i typed in Central/Vc, but when i hit enter, it automatically converted it to “vcov”.

it works now.
