I am trying to code a self-define model structure with ifelse statements in Phoenix nlme for a pop Pk model.
I would like to have a statement like this:
t_0=10
Ac_0=y0
if t < Tin
ddt_Ac = k * Ac - kel * Ac
else
ddt_Ac = - kel * Ac
Q1: Ac is target PK concentration, starting at day 10, and initial value should be fixed as a regression variable with subject ID which could be read from inputs.
How should I code to define start time and its subject dependent initial value?
k, kel and Tin are parameters needed to be fitted.
Q2: How to code if else statement with a uncertain condition (Tin needs to be fitted)?
I wrote a partial code for this model structure, please give me some suggestions for these two questions.
Thank you for your reply. I agree that I should use deriv(), instead of stparm()
The model is just a kinetics model, where is no dose. The model is used to fitting the data with two phases, production phase with k and decay phase with kel. I can solve the Q1 by chaning the initial time points. But I still need help for Q2, which is how to sturcture a two phase model.
I rewrote a code, but still couldn’t run successfully.
Thank you for your quick reply. The code can execute. What is sequence{Ac=10}, is that for set an initial value? I would like to set initial value at time 0 from data. Is that possible? I attached input dataset to make you more clear.
Thank you so much. The initial question Q1 is solved.
However, when I check the fitted population parameters, I found a problem:
I used Monolix for this fitting before. They can support if else statement as
if t < Tin
ddt_Ac = k * Ac - kel * Ac
else
ddt_Ac = - kel * Ac
And I found our approach gets a smaller value of k. I am thinking whether because we have some timepoints setting k as 0. Whether we have another way for coding this?
Thank you for your answer. I think if we set k =0 for phase 1, I will effect the population estimation value of k because theotically there should be no k value on phase1.