Hello all,
I would like to use time after last dose as a time-varying variable in differential equations. Is there any convenient way to do this? Though I saw a similar thread discussing tad in the dataset, I am posting here as my focus is time after dose in the @model . If not, would adding a column of time of last doing in the dataset and subtracting in the @model be the best way?
I have a βnormalβ multiple dose poppk dataset with a dose record for each dose (no addl doses) (one analyte) already assembled with time (time since first dose), id, evid, dv, amt, cmt, etc. What it lacks is time since the last dose (TSLD). Does anyone have Pumas/Julia code that will allow me to compute TSLD from the dataset of this format?
First, there are some restrictions on covariates names (as columns in a DataFrame
):
The following names are restricted form being used as covariate names: id
, amt
, time
, evid
, cmt
, rate
, duration
, ss
, ii
, route
, and tad
. These names are used for columns in the DataFrame
output form various Pumas objects, and therefore the names would clash when adding covariate information as columns.
Source: Defining NLME models in Pumas Β· Pumas
Finally, you can use the tad
function inside a Pumas @model
, see this MWE:
model = @model begin
@param begin
tvcl β RealDomain(lower = 0)
tvv β RealDomain(lower = 0)
Ξ© β PDiagDomain(2)
Ο_prop β RealDomain(lower = 0)
end
@random begin
Ξ· ~ MvNormal(Ξ©)
end
@pre begin
CL = tvcl * exp(Ξ·[1])
Vc = tvv * exp(Ξ·[2])
end
@dynamics Central1
@derived begin
cp := @. 1000 * (Central / Vc)
dv ~ @. Normal(cp, sqrt(cp^2 * Ο_prop))
end
@observed begin
mytad = tad(t, events)
end
end
ev = DosageRegimen(100; addl = 2, ii=1)
pops = map(i -> Subject(id = i, events = ev), 1:2)
sims = simobs(model, pops, init_params(model); obstimes = 0.5:3.5)
DataFrame(sims)
output:
julia> DataFrame(sims)
14Γ17 DataFrame
Row β id time dv mytad evid amt cmt rate duration ss ii route Ξ·_1 Ξ·_2 Central CL Vc
β String? Float64 Float64? Float64? Int64? Float64? Symbol? Float64? Float64? Int8? Float64? NCA.Route? Float64? Float64? Float64? Float64? Float64?
ββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
1 β 1 0.0 missing missing 1 100.0 Central 0.0 0.0 0 0.0 NullRoute 0.434505 -1.44498 missing 1.5442 0.235751
2 β 1 0.5 36690.0 0.5 0 missing missing missing missing missing missing missing 0.434505 -1.44498 3.78144 1.5442 0.235751
3 β 1 1.0 missing missing 1 100.0 Central 0.0 0.0 0 0.0 NullRoute 0.434505 -1.44498 missing 1.5442 0.235751
4 β 1 1.5 1433.44 0.5 0 missing missing missing missing missing missing missing 0.434505 -1.44498 3.78685 1.5442 0.235751
5 β 1 2.0 missing missing 1 100.0 Central 0.0 0.0 0 0.0 NullRoute 0.434505 -1.44498 missing 1.5442 0.235751
6 β 1 2.5 19090.6 0.5 0 missing missing missing missing missing missing missing 0.434505 -1.44498 3.78686 1.5442 0.235751
7 β 1 3.5 -8.84295 1.5 0 missing missing missing missing missing missing missing 0.434505 -1.44498 0.00541495 1.5442 0.235751
8 β 2 0.0 missing missing 1 100.0 Central 0.0 0.0 0 0.0 NullRoute -0.615916 1.89947 missing 0.540146 6.68237
9 β 2 0.5 30734.0 0.5 0 missing missing missing missing missing missing missing -0.615916 1.89947 96.039 0.540146 6.68237
10 β 2 1.0 missing missing 1 100.0 Central 0.0 0.0 0 0.0 NullRoute -0.615916 1.89947 missing 0.540146 6.68237
11 β 2 1.5 55271.4 0.5 0 missing missing missing missing missing missing missing -0.615916 1.89947 184.621 0.540146 6.68237
12 β 2 2.0 missing missing 1 100.0 Central 0.0 0.0 0 0.0 NullRoute -0.615916 1.89947 missing 0.540146 6.68237
13 β 2 2.5 48414.2 0.5 0 missing missing missing missing missing missing missing -0.615916 1.89947 266.324 0.540146 6.68237
14 β 2 3.5 127547.0 1.5 0 missing missing missing missing missing missing missing -0.615916 1.89947 245.643 0.540146 6.68237
Check the function tad
here: Pumas Docstrings Β· Pumas
1 Like