Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect F when F changes over the course of a lag time #1129

Closed
kylebaron opened this issue Nov 14, 2023 · 0 comments · Fixed by #1130
Closed

Incorrect F when F changes over the course of a lag time #1129

kylebaron opened this issue Nov 14, 2023 · 0 comments · Fixed by #1130
Assignees
Labels

Comments

@kylebaron
Copy link
Collaborator

Current behavior: bioavailability is set from whatever is in play at the time of a dose. This creates a problem when lag times are being used and the dose is actually given at a time when bioavailability has changed since the apparent administration.

In the example below, there is a lag time of 1 and both doses happen (apparently at time 0); so we should see
100 x 0.7 + 200 * 0.1 = 90 units in the dosing compartment at time 1. We don't see this because both doses see the 0.1 as the bioavailability.

library(mrgsolve)
#> 
#> Attaching package: 'mrgsolve'
#> The following object is masked from 'package:stats':
#> 
#>     filter

mod <- mread("1005", project = modlib())
#> Loading required namespace: xml2
#> Building 1005 ... done.

code <- '
$PARAM CL = 1, V = 10, KA = 1
$MAIN
ALAG_A = 1;
if(self.amt==100) F_A = 0.7; 
if(self.amt==200) F_A = 0.1;
$PKMODEL cmt = "A,B", depot = TRUE
'

mod <- mcode("foo", code)
#> Building foo ... done.

data <- data.frame(amt = c(100,200), evid = 1, time = 0, ID = 1, cmt = 1)

mrgsim(mod, data, recsort = 3, end = 1)
#> Model:  foo 
#> Dim:    4 x 4 
#> Time:   0 to 1 
#> ID:     1 
#>     ID time  A B
#> 1:   1    0  0 0
#> 2:   1    0  0 0
#> 3:   1    0  0 0
#> 4:   1    1 30 0

Created on 2023-11-13 with reprex v2.0.2

One solution is bioavailability gets stored in the record object early on and is always read from that specific record object rather than this global bioavailability floating around.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant