You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to understand how to capture the time and event of dosing in Dynamic dosing using reg. flag next () option. after running a test simulation when I try to filter out EVID >0 I get an empty dataset. Is the right way to use this? Thank you.
library(mrgsolve)
code <- '
$PROB Example of Dynamic Dosing within Mrgsolve
$PLUGIN evtools
$PARAM
// Typical model parameters
VC = 483.8
CRCL = 1.0
CLH = 22.7
ALC0 = 1.0
KOUT = 0.00065 // ZZZ c
EMAX = 457.0
// Covariates and individual parameters
WTKG = 50
EC50 = 1
// Dosing parameters
DOSE_CMT = 1
DOSE_NDOSE = 7
DOSE_LCYCLE1=504
DOSE_ENDTIME= 504*3
// Solver parameters
ATOL = 1E-8 // Default
$CMT
CENT
PD
$GLOBAL
evt::regimen reg; // create dosing regimen object
$MAIN
// Dynamic Dosing
double DOSEMG_IN = 10.0;
//if(WTKG < 50.0){ // ZZZ DUMMY: Update conditions and dosage based on weight buckets (starting/default dosage for first dose administered to each subject)
if(NEWIND <= 1){ // do once for each subject
reg.init(self); // initialize dosing regimen for dynamic dosing
reg.amt(DOSEMG_IN); // dose amt (mg)
reg.cmt(DOSE_CMT); // dosing cmt
reg.ii(DOSE_LCYCLE1); // within cycle dosing interval
reg.until(DOSE_ENDTIME); // last possible dose of simulation
reg.flagnext(); // flag time of each dose to ensure dynamic dosing if the time is not already captured within the observation time grid (i.e., EVID = 0)
double DRUG_ON = 1.0;
double POSTPONE = 0.0;
double TPOSTPONE = 0.0;
}
double DOSE_OUT = reg.amt();
// PK and PK-PD Model
double CLR=CRCL;
double CL = CLH + CLR;
double KE = CL/VC;
double KIN = ALC0*KOUT;
PD_0 = ALC0;
$ODE
// PK and PK-PD Model
dxdt_CENT = -KE*CENT;
double CP = 1000.0*(CENT/VC); // unit conversion mg/L to ng/mL ?
if(CP < ATOL){ // concentration will oscillate and become negative when near absolute tolerance
CP = 0.0;
}
double EFFECT = 0.0;
if(CP > 0){
EFFECT = EMAX*CP/(EC50+CP);
}
dxdt_PD = KIN - KOUT*(1.0+EFFECT)*PD;
$OMEGA 0.0 // placeholder
$ERROR
double REPEAT = std::floor(TIME/504.0)+1.0; // calculate current repeat (i.e., year)
double REPEAT_TIME = TIME - (REPEAT-1.0)*504.0;
double CYCLE = std::floor(REPEAT_TIME/504.0)+1.0; // Each cycle is 504 hours (3 weeks)
double CYCLE_TIME = REPEAT_TIME - (CYCLE-1.0)*504.0;
double DOSEN = std::floor(CYCLE_TIME/168.0)+1.0; // Smallest interval is 168 hours (1 week)
double DOSE_TIME = CYCLE_TIME - (DOSEN-1.0)*168.0;
if(TIME == 504.00) {
reg.amt(DOSEMG_IN/2.0);
}
if(TIME == 1008.00) {
reg.amt(DOSEMG_IN/2.0);
}
reg.execute(); // execute the dosing regimen created within mrgsolve code
$TABLE
double PD1 = PD;
double PD_BX = (pow(PD1, 0.2) - 1.0)/0.2; // Calculating PD_BX here
$CAPTURE WTKG EC50 CP REPEAT CYCLE DOSEN REPEAT_TIME CYCLE_TIME DOSE_TIME DRUG_ON DOSE_OUT POSTPONE TPOSTPONE PD_BX EVID
'
mod<-mcode('example_test',code)
idata <- expand.idata(ID = 1:3)
set.seed(12345)
out <- mrgsim(
mod,
idata = idata,
end = 9*168
)
plot(out,CP+PD+CYCLE_TIME+EVID~time)
head(out)
out %>% filter(EVID>0)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
I want to understand how to capture the time and event of dosing in Dynamic dosing using
reg. flag next ()
option. after running a test simulation when I try to filter out EVID >0 I get an empty dataset. Is the right way to use this? Thank you.Beta Was this translation helpful? Give feedback.
All reactions