# Using Michalis - Menten in Linear ODE approach

Hi .
I tried to use Michalis - Menten Approach in Linear ODE model. It shows got below error .
Can someone help me to do this

``````julia> result  = fit(MMbasemodel1,pumdf1, MMbm1param1, Pumas.FOCEI(),ensemblealg = EnsembleThreads())
ERROR: UndefVarError: Central not defined
Stacktrace:
[1] (::var"#883#907"{NamedTuple{(:tvka, :tvk23, :tvQ, :tvvc, :tvvp, :tvvmax, :tvbio1, :tvkm, :Ω, :σ),Tuple{Float64,Float64,Int64,Float64,Int64,Int64,Float64,Int64,Diagonal{Float64,Array{Float64,1}},Float64}},NamedTuple{(:η,),Tuple{FillArrays.Zeros{Float64,1,Tuple{Base.OneTo{Int64}}}}},Subject{NamedTuple{(:DV,),Tuple{Array{Union{Missing, Float64},1}}},Pumas.ConstantCovar{NamedTuple{,Tuple{}}},Array{Pumas.Event{Float64,Float64,Float64,Float64,Float64,Float64,Nothing,Int64},1},Array{Float64,1}}})(::Pumas.Pre{Nothing,var"#883#907"{NamedTuple{(:tvka, :tvk23, :tvQ, :tvvc, :tvvp, :tvvmax, :tvbio1, :tvkm, :Ω, :σ),Tuple{Float64,Float64,Int64,Float64,Int64,Int64,Float64,Int64,Diagonal{Float64,Array{Float64,1}},Float64}},NamedTuple{(:η,),Tuple{FillArrays.Zeros{Float64,1,Tuple{Base.OneTo{Int64}}}}},Subject{NamedTuple{(:DV,),Tuple{Array{Union{Missing, Float64},1}}},Pumas.ConstantCovar{NamedTuple{,Tuple{}}},Array{Pumas.Event{Float64,Float64,Float64,Float64,Float64,Float64,Nothing,Int64},1},Array{Float64,1}}}}, ::Float64) at C:\Users\julia\.julia\packages\Pumas\iIBBr\src\dsl\model_macro.jl:436
[2] Pre at C:\Users\julia\.julia\packages\Pumas\iIBBr\src\dsl\model_macro.jl:404 [inlined]
[3] #884 at C:\Users\julia\.julia\packages\Pumas\iIBBr\src\dsl\model_macro.jl:111 [inlined]
[4] _check_dose_compartments(::PumasModel{ParamSet{NamedTuple{(:tvka, :tvk23, :tvQ, :tvvc, :tvvp, :tvvmax, :tvkm, :tvbio1, :Ω, :σ),Tuple{RealDomain{Float64,Int64,Float64},RealDomain{Float64,Int64,Float64},RealDomain{Float64,Int64,Float64},RealDomain{Float64,Int64,Float64},RealDomain{Float64,Int64,Float64},RealDomain{Float64,Int64,Float64},RealDomain{Float64,Int64,Float64},RealDomain{Float64,Int64,Float64},PDiagDomain{PDMats.PDiagMat{Float64,Array{Float64,1}}},RealDomain{Float64,Int64,Float64}}}},var"#881#905",var"#882#906",var"#884#908",Pumas.LinearODE,var"#885#909",var"#895#919"}, ::Subject{NamedTuple{(:DV,),Tuple{Array{Union{Missing, Float64},1}}},Pumas.ConstantCovar{NamedTuple{,Tuple{}}},Array{Pumas.Event{Float64,Float64,Float64,Float64,Float64,Float64,Nothing,Int64},1},Array{Float64,1}}, ::NamedTuple{(:tvka, :tvk23, :tvQ, :tvvc, :tvvp, :tvvmax, :tvbio1, :tvkm, :Ω, :σ),Tuple{Float64,Float64,Int64,Float64,Int64,Int64,Float64,Int64,Diagonal{Float64,Array{Float64,1}},Float64}}) at C:\Users\julia\.julia\packages\Pumas\iIBBr\src\estimation\likelihoods.jl:1904
[5] #354 at C:\Users\julia\.julia\packages\Pumas\iIBBr\src\estimation\likelihoods.jl:1997 [inlined]
[6] iterate at .\generator.jl:47 [inlined]
[7] _collect(::Array{Subject{NamedTuple{(:DV,),Tuple{Array{Union{Missing, Float64},1}}},Pumas.ConstantCovar{NamedTuple{,Tuple{}}},Array{Pumas.Event{Float64,Float64,Float64,Float64,Float64,Float64,Nothing,Int64},1},Array{Float64,1}},1}, ::Base.Generator{Array{Subject{NamedTuple{(:DV,),Tuple{Array{Union{Missing, Float64},1}}},Pumas.ConstantCovar{NamedTuple{,Tuple{}}},Array{Pumas.Event{Float64,Float64,Float64,Float64,Float64,Float64,Nothing,Int64},1},Array{Float64,1}},1},Pumas.var"#354#355"{PumasModel{ParamSet{NamedTuple{(:tvka, :tvk23, :tvQ, :tvvc, :tvvp, :tvvmax, :tvkm, :tvbio1, :Ω, :σ),Tuple{RealDomain{Float64,Int64,Float64},RealDomain{Float64,Int64,Float64},RealDomain{Float64,Int64,Float64},RealDomain{Float64,Int64,Float64},RealDomain{Float64,Int64,Float64},RealDomain{Float64,Int64,Float64},RealDomain{Float64,Int64,Float64},RealDomain{Float64,Int64,Float64},PDiagDomain{PDMats.PDiagMat{Float64,Array{Float64,1}}},RealDomain{Float64,Int64,Float64}}}},var"#881#905",var"#882#906",var"#884#908",Pumas.LinearODE,var"#885#909",var"#895#919"},NamedTuple{(:tvka, :tvk23, :tvQ, :tvvc, :tvvp, :tvvmax, :tvbio1, :tvkm, :Ω, :σ),Tuple{Float64,Float64,Int64,Float64,Int64,Int64,Float64,Int64,Diagonal{Float64,Array{Float64,1}},Float64}}}}, ::Base.EltypeUnknown, ::Base.HasShape{1}) at .\array.jl:699
[8] collect_similar at .\array.jl:628 [inlined]
[9] map at .\abstractarray.jl:2162 [inlined]
[10] fit(::PumasModel{ParamSet{NamedTuple{(:tvka, :tvk23, :tvQ, :tvvc, :tvvp, :tvvmax, :tvkm, :tvbio1, :Ω, :σ),Tuple{RealDomain{Float64,Int64,Float64},RealDomain{Float64,Int64,Float64},RealDomain{Float64,Int64,Float64},RealDomain{Float64,Int64,Float64},RealDomain{Float64,Int64,Float64},RealDomain{Float64,Int64,Float64},RealDomain{Float64,Int64,Float64},RealDomain{Float64,Int64,Float64},PDiagDomain{PDMats.PDiagMat{Float64,Array{Float64,1}}},RealDomain{Float64,Int64,Float64}}}},var"#881#905",var"#882#906",var"#884#908",Pumas.LinearODE,var"#885#909",var"#895#919"}, ::Array{Subject{NamedTuple{(:DV,),Tuple{Array{Union{Missing, Float64},1}}},Pumas.ConstantCovar{NamedTuple{,Tuple{}}},Array{Pumas.Event{Float64,Float64,Float64,Float64,Float64,Float64,Nothing,Int64},1},Array{Float64,1}},1}, ::NamedTuple{(:tvka, :tvk23, :tvQ, :tvvc, :tvvp, :tvvmax, :tvbio1, :tvkm, :Ω, :σ),Tuple{Float64,Float64,Int64,Float64,Int64,Int64,Float64,Int64,Diagonal{Float64,Array{Float64,1}},Float64}}, ::Pumas.FOCEI; optimize_fn::Pumas.DefaultOptimizeFN{Nothing,NamedTuple{(:show_trace, :store_trace, :extended_trace, :g_tol, :allow_f_increases),Tuple{Bool,Bool,Bool,Float64,Bool}}}, constantcoef::NamedTuple{,Tuple{}}, omegas::Tuple{}, ensemblealg::EnsembleThreads, checkidentification::Bool, kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{,Tuple{}}}) at C:\Users\julia\.julia\packages\Pumas\iIBBr\src\estimation\likelihoods.jl:1997
[11] top-level scope at none:1
``````

and my model is

`````````julia
MMbasemodel1 = @model begin
@param begin
tvka  ∈ RealDomain(lower=0.1, upper = 5)
tvk23 ∈ RealDomain(lower=0.1, upper = 20 )
tvQ   ∈ RealDomain(lower=0.1, upper = 250 )
tvvc  ∈ RealDomain(lower=0.1, upper = 250)
tvvp  ∈ RealDomain(lower=0.1, upper = 250)
tvvmax ∈ RealDomain(lower=0.1,upper = 50)
tvkm  ∈ RealDomain(lower =0.1, upper = 50)
tvbio1 ∈ RealDomain(lower=0.1, upper =1)
Ω     ∈ PDiagDomain(8) # CL = 0.23,Vc = 0.72,KA = 3.37,vp = 0.04,k23 = 0.09
σ     ∈ RealDomain(lower=0.01,upper = 1)
end
@random begin
η ~ MvNormal(Ω)
end
#@covariates Wt

@pre begin
ka    = tvka * exp(η[1])
k23   = tvk23 * exp(η[2])
Q     = tvQ  * exp(η[3])
vc    = tvvc * exp(η[4])
vp    = tvvp * exp(η[5])
vmax  = tvvmax * exp(η[6])
bioav = (Depot1 = tvbio1* exp(η[7]))
km   = tvkm * exp(η[8])
A = @SMatrix([-ka    0      0           0
0    -k23    0           0
ka    k23  -(((vmax/vc)/(km+(Central/vc))) +(Q/vc))   Q/vp
0       0    Q/vc       -Q/vp  ])
end
@init begin
Depot1 = 0.0
Prodrug = 0.0
Central = 0.0
Peripheral = 0.0
end
@dynamics LinearODE
@derived begin
conc := @. Central/vc
DV ~ @. Normal(conc, σ*abs(conc))
end
end
``````

i have tried @Vars as well , it did not work

Machaelis-Menten kinetics is not described by a linear ODE so you can’t use `LinearODE` for this.

2 Likes