Parameter having time function

Hello,

Part of my model is here and I have an issue regarding ECMO_CL in the pre block.

  @pre begin
    non_ECMO_CL    =  POPCL * (FFM/70)^0.75 * (0.3/SCR)^θscr * (1/(1 + (PMA/41)^θpma))
    ECMO_CL        =  max_ecmo_CL * (1 - exp(-θecmo_cl * t)) * isECMO

    TVVc    =  POPVc * (FFM/70) * θage^log(AGEYRS/0.28)

    CL      =  non_ECMO_CL * (1 + ECMO_CL) * exp(η[1])
    Vc      =  TVVc * exp(η[2])
    Ka      =  POPKa
  end

  @dynamics begin
      # 1cmt
      Depot'   = -Ka * Depot
      Central' =  Ka * Depot - Central * (CL/Vc)
  end

  @derived begin
      CP            =  @. Central/Vc
      DV            ~  @. Normal(CP, abs(CP) * σ_prop)
  end

  @observed begin
    non_ECMO_TVCL = non_ECMO_CL
    ECMO_TVCL     = ECMO_CL
    CLi          = CL
    Vi           = Vc
  end
end

Also, I build a population for the simulation.

pop = map(i -> Subject(id = i, events = e_neonate, 
              covariates = (FFM = 2.63, AGEYRS = 0.0833, PMA = 40, SCR = 0.77, isECMO = 1,)), 1:1000)
sims = simobs(model, pop, param, obstimes = 0:1:10)

I expected to have time-varying ECMO_TVCL and CLi in the simulation results, but ECMO_TVCL was estimated as zero. When I fitted the model, ECMO_TVCL and CLi was time-varying as I expected. Am I doing something incorrectly?
Thank you!

Hello, @vijay and @andreasnoack.
I tried to debug and merged non_ECMO_CL and ECMO_CL into TVCL, but still TVCL doesn’t involve internal t part. Could you please advise how to deal with this?
Thank you!

    @pre begin
       #non_ECMO_CL    =  POPCL * (FFM/70)^0.75 * (0.3/SCR)^θscr * (1/(1 + (PMA/41)^θpma))
       #ECMO_CL        =  max_ecmo_CL * (1 - exp(-θecmo_cl * t)) * isECMO

       TVCL =     POPCL * (FFM/70)^0.75 * (0.3/SCR)^θscr * (1/(1 + (PMA/41)^θpma)) * (1 + max_ecmo_CL * (1 - exp(-θecmo_cl * t)))

       TVVc    =  POPVc * (FFM/70) * θage^log(AGEYRS/0.28)

       #CL      =  non_ECMO_CL * (1 + ECMO_CL) * exp(η[1])
       CL      = TVCL * exp(η[1])
       Vc      =  TVVc * exp(η[2])
       Ka      =  POPKa
    end

Could you please send the entire script for simulation @Dawoon . It will help us debug

Thank you for your response, Dr. @vijay Ivaturi. Here’s the entire script for simulation. Thank you for your help!

ecmo_cov_model = @model begin

    @param begin
        POPCL        ∈ RealDomain(lower=0.0)
        θscr         ∈ RealDomain(lower=0.0)
        θpma         ∈ RealDomain(lower=-100)
        POPVc        ∈ RealDomain(lower=0.0)
        θage         ∈ RealDomain(lower=0.0)
        POPKa        ∈ RealDomain(lower=0.0)
        POPBioav     ∈ RealDomain(lower=0.0)
        max_ecmo_CL  ∈ RealDomain(lower=0.0) # maximal fractional increase of CL during ECMO
        θecmo_cl     ∈ RealDomain(lower=0.0) # ECMO CL first order rate constant
        Ω1           ∈ PDiagDomain(2) #BSV for CL and Vc
        σ_prop       ∈ RealDomain(lower=0.0)
    end

    @random begin
        η   ~   MvNormal(Ω1)

    end

    @covariates FFM AGEYRS PMA SCR isECMO

    @pre begin
       non_ECMO_CL    =  POPCL * (FFM/70)^0.75 * (0.3/SCR)^θscr * (1/(1 + (PMA/41)^θpma))
       ECMO_CL        =  max_ecmo_CL * (1 - exp(-θecmo_cl * t)) * isECMO
       TVVc    =  POPVc * (FFM/70) * θage^log(AGEYRS/0.28)

       CL      =  non_ECMO_CL * (1 + ECMO_CL) * exp(η[1])
       Vc      =  TVVc * exp(η[2])
       Ka      =  POPKa
    end

    @dosecontrol begin
       bioav   =  (Depot = POPBioav,)
    end

    @dynamics begin
       # 1cmt
       Depot'   = -Ka * Depot
       Central' =  Ka * Depot - Central * (CL/Vc)
    end

    @derived begin
       CP            =  @. Central/Vc
       DV            ~  @. Normal(CP, abs(CP) * σ_prop)
    end

    @observed begin
       non_ECMO_TVCL   = non_ECMO_CL
       ECMO_TVCL       = ECMO_CL
       CLi             = CL
       Vi              = Vc
    end
end



ecmo_cov_param = (POPCL        =  0.372, 
                  θscr         =  0.265,
                  θpma         =  -4.22, 
                  POPVc        =  62.5,
                  θage         =  0.981, 
                  POPKa        =  0.8, 
                  POPBioav     =  0.89, 
                  max_ecmo_CL  =  2.2855, 
                  θecmo_cl     =  0.014066,
                  Ω1           =  Diagonal([0.1814, 0.1052]), 
                  σ_prop       =  0.148)


#
# Dosing regimen

# 15mg/kg loading dose
e_neonate_15_loading = DosageRegimen(55.5, time = 0, cmt = 2, duration = 0.5)

# Population
# 15mg/kg loading dose
pop_neonate_15_loading = map(i -> Subject(id = i, events = e_neonate_15_loading, 
              covariates = (FFM = 2.63, AGEYRS = 0.0833, PMA = 40, SCR = 0.77, isECMO = 1,)), 1:1000)

# Random effect
Random.seed!(101321)
randeffs = sample_randeffs(ecmo_cov_model, ecmo_cov_param, pop_neonate_15_loading)


# Simulation
Random.seed!(101321)
sims_neonate_15_loading = simobs(ecmo_cov_model, pop_neonate_15_loading, ecmo_cov_param, randeffs, obstimes = 0:0.5:10)
DataFrame(sims_neonate_15_loading)