Issue with PK02 exercise "simobs"

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:

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

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);

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.

1 Like