# Exercise PK04 - One compartment oral dosing

### Background

• Structural model - One compartment linear elimination with first order absorption.

• Route of administration - Oral, Multiple dosing

• Dosage Regimen - 352.3 μg

• Number of Subjects - 1 ### Learning Outcome

This is a one compartment multiple oral dosing model. In the exercise pk04, four models are compared.

• Model 1 - One compartment model without lag-time, distinct parameters Ka and K

• Model 2 - One compartment model with lag time, distinct parameters Ka and K

• Model 3 - One compartment model without lag time, Ka = K = K¹

• Model 4 - One compartment model with lag time, Ka = K = K¹

### Objectives

In this tutorial, you will learn how to build one compartment model for multiple oral dosing and to simulate the model for a single subject.

### Libraries

call the "necessary" libraries to get start.

using Pumas
using Plots
using CSV
using StatsPlots
using Random


### Model 1 & 2

In this one compartment model, we administer multiple doses orally.

pk_04_1_2    = @model begin
@param begin
tvka     ∈ RealDomain(lower=0)
tvk      ∈ RealDomain(lower=0)
tvvc     ∈ RealDomain(lower=0)
tvlag    ∈ RealDomain(lower=0)
Ω        ∈ PDiagDomain(3)
σ²_prop  ∈ RealDomain(lower=0)
end

@random begin
η        ~ MvNormal(Ω)
end

@pre begin
Ka       = tvka * exp(η)
K        = tvk * exp(η)
Vc       = tvvc * exp(η)
lags     = (Depot = tvlag,)
end

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

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

PumasModel
Parameters: tvka, tvk, tvvc, tvlag, Ω, σ²_prop
Random effects: η
Covariates:
Dynamical variables: Depot, Central
Derived: cp, dv
Observed: cp, dv


### Parameters

The parameters are as given below. tv represents the typical value for parameters.

• Ka - Absorption Rate Constant (hr⁻¹),

• K - Elimination Rate Constant (hr⁻¹),

• Vc - Volume of Central Compartment(L),

• Ω - Between Subject Variability,

• σ - Residual error

param1 = (tvka    = 0.14,
tvk     = 0.14,
tvvc    = 56.6,
tvlag   = 0,
Ω       = Diagonal([0.0,0.0,0.0]),
σ²_prop = 0.015)

(tvka = 0.14, tvk = 0.14, tvvc = 56.6, tvlag = 0, Ω = [0.0 0.0 0.0; 0.0 0.0
0.0; 0.0 0.0 0.0], σ²_prop = 0.015)

param2 = (tvka    = 0.20,
tvk     = 0.12,
tvvc    = 64.9,
tvlag   = 0.70,
Ω       = Diagonal([0.0,0.0,0.0]),
σ²_prop = 0.01)

(tvka = 0.2, tvk = 0.12, tvvc = 64.9, tvlag = 0.7, Ω = [0.0 0.0 0.0; 0.0 0.
0 0.0; 0.0 0.0 0.0], σ²_prop = 0.01)


### Dosage Regimen

Subject received 352.3 μg of oral dose once a day for 10 days.

ev1  = DosageRegimen(352.3, time=0, ii=24, addl=9, cmt=1)
sub1 = Subject(id=1, events=ev1)
sub2 = Subject(id=2, events=ev1)


### Simulation

Simulation the plasma concentration of the drug after multiple oral dosing

## Model 1 - without lag time
Random.seed!(123)
sim_sub1 = simobs(pk_04_1_2,sub1,param1,obstimes= 0:0.1:240)
df1      = DataFrame(sim_sub1)

## Model 2 - with lag time
Random.seed!(123)
sim_sub2 = simobs(pk_04_1_2,sub2,param2,obstimes= 0:0.1:240)
df2      = DataFrame(sim_sub2)


### Plots

df2_dv = filter(x -> x.time in [1,2,3,4,5,6,7,8,10,12,14,24,216,216.5,217,218,219,220,221,222,223,224,226,228,230,240], df2)

@df df1 plot(:time, :cp,
xlabel = "Time (hr)", ylabel = "Concentration (ug/L)", label = "Pred-Without lag-time",
title = "Plasma Concentration vs Time", linewidth = 3, legend=:outerright,
xticks = [0,24,48,72,96,120,144,168,192,216,240], ylims=(0,3.0))
@df df2 plot!(:time, :cp, label = "Pred-With lag-time", linewidth=3)
@df df2_dv scatter!(:time, :dv, label="Obs-Conc") 