# Exercise PK39 - Two Compartment data-Experimental design issues

### Background

• Structural model - Two compartment linear elimination with zero order absorption

• Route of administration - Three consecutive constant rate IV infusion

• Dosage Regimen - 1st dose:- 26.9 mcg/kg over 15min, 2nd dose:- 139 mcg/kg from 15min to 8hr, 3rd dose:- 138.95 mcg/kg between 8hr to 24hr

• Number of Subjects - 1 ### Objectives

In this model you will learn how to build a two compartment model and simulate for a single subject.

### Libraries

Call the "necessary" libraries to get start.

using Random
using Pumas
using PumasUtilities
using CairoMakie


### Model

In this two compartment model we administer three consecutive IV infusion for a single subject and we assess the disposition of drug and fitting the model to the observed data.

pk_39           = @model begin
desc        = "Two Compartment Model"
timeu       = u"hr"
end

@param begin
"Clearance (L/kg/hr)"
tvcl        ∈ RealDomain(lower=0)
"Volume of Central Compartment (L/kg)"
tvvc        ∈ RealDomain(lower=0)
"Volume of Peripheral Compartment (L/kg)"
tvvp        ∈ RealDomain(lower=0)
"Intercompartmental clearance (L/kg/hr)"
tvq         ∈ RealDomain(lower=0)
Ω           ∈ PDiagDomain(4)
"Proportional RUV"
σ²_prop     ∈ RealDomain(lower=0)
end

@random begin
η           ~ MvNormal(Ω)
end

@pre begin
CL          = tvcl * exp(η)
Vc          = tvvc * exp(η)
Vp          = tvvp * exp(η)
Q           = tvq * exp(η)
end

@dynamics begin
Central'    =  (Q/Vp)*Peripheral - (Q/Vc)*Central -(CL/Vc)*Central
Peripheral' = -(Q/Vp)*Peripheral + (Q/Vc)*Central
end

@derived begin
cp          = @. Central/Vc
"""
Observed Concentration (ug/L)
"""
dv          ~ @. Normal(cp, sqrt(cp^2*σ²_prop))
end
end

PumasModel
Parameters: tvcl, tvvc, tvvp, tvq, Ω, σ²_prop
Random effects: η
Covariates:
Dynamical variables: Central, Peripheral
Derived: cp, dv
Observed: cp, dv


### Parameters

Parameters provided for simulation. tv represents the typical value for parameters.

• $Cl$ - Clearance (L/kg/hr)

• $Vc$ - Volume of Central Compartment (L/kg)

• $Vp$ - Volume of Peripheral Compartment (L/kg)

• $Q$ - Intercompartmental clearance (L/kg/hr)

• $Ω$ - Between Subject Variability

• $σ$ - Residual error

param = (tvcl    = 0.417793,
tvvc    = 0.320672,
tvvp    = 2.12265,
tvq     = 0.903188,
Ω       = Diagonal([0.0,0.0,0.0,0.0]),
σ²_prop = 0.005)

(tvcl = 0.417793, tvvc = 0.320672, tvvp = 2.12265, tvq = 0.903188, Ω = [0.0
0.0 0.0 0.0; 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0], σ²_prop =
0.005)


### Dosage Regimen

Single subject receiving three consecutive IV infusion

• 1st dose: 26.9 mcg/kg over 15min

• 2nd dose: 139 mcg/kg from 15min to 8hr

• 3rd dose: 138.95 mcg/kg between 8hr to 24hr

ev1  = DosageRegimen([26.9,139,138.95], time=[0,0.25,8], cmt=1, duration=[0.25,7.85,16])
sub1 = Subject(id=1, events=ev1)

Subject
ID: 1
Events: 6


### Simulation

Lets simulate for plasma concentration with the specific observation time points after IV infusion.

Random.seed!(123)
sim_sub1 = simobs(pk_39, sub1, param, obstimes=0:0.01:60)


### Visualization

f1, a1, p1 = sim_plot(pk_39, [sim_sub1],
observations = :cp,
color = :redsblues,
linewidth = 4,
axis = (
xlabel = "Time (hr)",
ylabel = "PK39 Concentrations (μg/L)",
xticks = 0:10:60))
f1
{"ft_lang_label":"__label__en","ft_lang_prob":0.7346853,"math_prob":0.9876742,"size":2932,"snap":"2021-31-2021-39","text_gpt3_token_len":1017,"char_repetition_ratio":0.113046445,"word_repetition_ratio":0.082004555,"special_character_ratio":0.3574352,"punctuation_ratio":0.19162641,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9820281,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,3,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-09-17T16:02:13Z\",\"WARC-Record-ID\":\"<urn:uuid:f26e1538-d22e-45bb-a5e3-cf23fccd79cb>\",\"Content-Length\":\"71481\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:876055b0-0b9b-405e-a762-eb17e6368dca>\",\"WARC-Concurrent-To\":\"<urn:uuid:99630db0-c505-47db-88db-9ef1037889e7>\",\"WARC-IP-Address\":\"35.185.44.232\",\"WARC-Target-URI\":\"https://tutorials.pumas.ai/html/PKPDDataAnalysisBook/PK/pk39.html\",\"WARC-Payload-Digest\":\"sha1:3AMSO3W7JE4XYBJ4U24KV2EYWH6BHKS3\",\"WARC-Block-Digest\":\"sha1:ZVFYD5Q4S7HABMV4F3WBDAZ5M6NTVKMX\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-39/CC-MAIN-2021-39_segments_1631780055684.76_warc_CC-MAIN-20210917151054-20210917181054-00155.warc.gz\"}"}