How to account for lag time in absorption model

hi
i am trying to write one compartment first order absorption model with lag time . i have a doubt on how to write lag time in model. here i am showing the model which i have written , this model worked but did not give the exact result. please review it once and suggest me the changed where it is needed

model = @model begin

    @param begin

        tvcl ∈ RealDomain(lower=0, init = 1.0)
        tvv ∈ RealDomain(lower=0, init = 100)
        tvka ∈ RealDomain(lower = 0, init= 0.5)
        tvlag ∈ RealDomain(lower = 0, init = 0.5)
        Ω ∈ PDiagDomain(init=[0.04])
        σ ∈ RealDomain(lower=0,init=0.01)

    end
    @random begin
   
   η ~ MvNormal(Ω)
     
    end
    @pre begin
      CL = tvcl *  exp(η[1])
      V  = tvv
      ka = tvka
      lag  = tvlag
    end
   
    @dynamics begin
            Depot' =  - ka * Depot
            Central' = ka * Depot - (CL/V) * Central
    end

    @vars begin
           Depot  =  Depot
           Cent   =  Central/V
          
       end

       @derived begin
           cp = Cent
       
           dv ~ @. Normal(cp, abs(cp)*σ)
         end

end



lags, bioav, rate and duration come under what are called as Dose Control Parameters
you can read the docs to understand more. But in your example, this is how it is done

using Pumas
using Plots

model = @model begin

    @param begin

        tvcl ∈ RealDomain(lower=0, init = 1.0)
        tvv ∈ RealDomain(lower=0, init = 100)
        tvka ∈ RealDomain(lower = 0, init= 0.5)
        tvlag ∈ RealDomain(lower = 0, init = 0.5)
        Ω ∈ PDiagDomain(init=[0.04])
        σ ∈ RealDomain(lower=0,init=0.01)

    end
    @random begin
   
   η ~ MvNormal(Ω)
     
    end
    @pre begin
      CL = tvcl *  exp(η[1])
      V  = tvv
      ka = tvka
      lags  = (Depot = tvlag,)
    end
   
    @dynamics begin
            Depot' =  - ka * Depot
            Central' = ka * Depot - (CL/V) * Central
    end

       @derived begin
           cp = Central/V
       
           dv ~ @. Normal(cp, abs(cp)*σ)
         end

end

ev1 = DosageRegimen(150, cmt=1)
pop = Population(map(i -> Subject(id=i,evs=ev1),1:10))

lagmodel_params = (tvcl = 1.5,
                tvv = 25.0,
                tvka = 1,
                tvlag = 10,
                Ω = Diagonal([0.05]),
                σ = 0.02)
sims = simobs(model, pop, lagmodel_params, obstimes = 0:1:48)
plot(sims)

Notice how I specified a parameter called lags (which is a reserved name). This is used to then create a list of compartments which are associated with a parameter that becomes the lag of that compartment. Same applies for bioav and other too. In the example I used an extreme lag of 10 hours just to illustrate

here is the plot of that simulation above

hope that helps!

yeah, it really helped me. ill try this and get back to you with result. thankyou very much