Closed StevenLShafer closed 5 years ago
Hi Steve:
Nice to hear from you.
There're multiple ways of doing what you described. One simple way is to use the built-in variable t (for time) and the "if" to denote a change of parameter(s) with time. A snippet of example is given below.
ode = " ... if (t < 10) { CL = CL1; } else { CL = CL2; } ... "
In this case, you'll need both CL1 and CL2 in your parameters.
Hope it helps.
Best, Wenping
Dear Wenping:
Wow, that was fast!
I understand the code and will give it a try.
The text below translates readily into C. However, can the quoted code include something like “i <- tail(which(pkTimes <= t),1)”. This will return the index to my parameter array. However, I’m not sure how much R code is allowed within the quotation marks. My guess is that R code won’t work, and the easiest approach will be to chain if statements.
Thanks!
Steve
From: wwang-at-github notifications@github.com Sent: Monday, July 29, 2019 7:20 PM To: nlmixrdevelopment/RxODE RxODE@noreply.github.com Cc: Steven L Shafer Steven.Shafer@stanford.edu; Author author@noreply.github.com Subject: Re: [nlmixrdevelopment/RxODE] Time varying parameters (#104)
Hi Steve:
Nice to hear from you.
There're multiple ways of doing what you described. One simple way is to use the built-in variable t (for time) and the "if" to denote a change of parameter(s) with time. A snippet of example is given below.
ode = " ... if (t < 10) { CL = CL1; } else { CL = CL2; } ... "
In this case, you'll need both CL1 and CL2 in your parameters.
Hope it helps.
Best, Wenping
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/nlmixrdevelopment/RxODE/issues/104?email_source=notifications&email_token=AFHWJTYIGHUEDF7HOJMWEJDQB4REVA5CNFSM4IHTAVDKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3BMXRA#issuecomment-516082628, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AFHWJTZXJ646VXU77E3ABP3QB4REVANCNFSM4IHTAVDA.
Hi @StevenLShafer
Just as Wenping suggested there is multiple ways to address this. Another is to add the covariates to the event table.
Using Wenping's to illustrate the alternate approach:
library(RxODE)
mod1 <-RxODE({
## central
KA=2.94E-01;
tCL1=1.86E+01;
tCL2 = 7
V2=4.02E+01;
## peripheral
Q=1.05E+01;
V3=2.97E+02;
CL = cov * tCL1 + (1 - cov) * tCL2
## Effects
Kin=1;
Kout=1;
EC50=200;
## ODE model
C2 = centr/V2;
C3 = peri/V3;
d/dt(depot) =-KA*depot;
d/dt(centr) = KA*depot - CL*C2 - Q*C2 + Q*C3;
d/dt(peri) = Q*C2 - Q*C3;
d/dt(eff) = Kin - Kout*(1-C2/(EC50+C2))*eff;
});
## You may use eventTable()
et <- et() %>%
et(amt=10000, until=240, ii=12) %>%
et(amt=20000, time=120, ii=24, until=240) %>%
et(0:240) ## Add sampling
## Now add covariates; You can use any R expressions you want for the
## covariates
et$cov <- 1
et$cov[et$time < 120] <- 0
s <- mod1 %>% solve(et)
s %>% plot(centr, eff)
Created on 2019-07-29 by the reprex package (v0.3.0)
RxODE can take now take NONMEM-style data-frames from R. Therefore your “i <- tail(which(pkTimes <= t),1)
should be able to work if you apply it to the data-frame before running the solving routine.
For more information you can see the following documentation:
Let us know if you have any more questions or issues @StevenLShafer
I want to use RxODE for simulation where the PK parameters abruptly change with events (specifically, the onset/offset of cardipulmonary bypass). I can call RxODE 3 times: before bypass, during bypass, and after bypass. However, there does not seem to be a way of entering a matrix of time-specific PK parameters. Is this possible?
Thank you