Hello,
Just a follow up on my question, after I modified the param block, the fitting process works, but the infer(fit) returned an error that it could not calculate the SE, the complete codes and error message is shown below.
Codes:
@time using Distributions, Pumas, CSV, TableView, StatsPlots, DataFrames
ped_mod = @model begin
@param begin
θ ~ MvNormal([16.6,13.1,4.05,4.89,0.623,0,0,0],
Matrix{Float64}([0.0895 0.0167 0.00318 0.0033 0.000907 0 0 0;
0.0167 0.0655 -0.00765 0.00333 -0.000917 0 0 0;
0.00318 -0.00765 0.0238 0.0147 -0.000225 0 0 0;
0.0033 0.00333 0.0147 0.0161 -0.000243 0 0 0;
0.000907 -0.000917 -0.000225 -0.000243 0.0016 0 0 0;
0 0 0 0 0 1000000 0 0;
0 0 0 0 0 0 1000000 0;
0 0 0 0 0 0 0 1000000]))
Ω ∈ PDiagDomain(3)
σ_prop ∈ RealDomain(lower = 0)
end
@random begin
η ~ MvNormal(Ω)
end
@covariates WTKG CRCL
@pre begin
COV1=(CRCL/100)^θ[5]
COV2=(WTKG/70)^θ[6]
COV3=(WTKG/70)^θ[7]
COV4=(WTKG/70)^θ[8]
TVCLI = θ[1]*COV1*COV4
TVCL = TVCLI
TVV1I = θ[2]*COV2
TVV1 = TVV1I
TVQI = θ[3]
TVQ = TVQI
TVV2I = θ[4]*COV3
TVV2 = TVV2I
CL = TVCL*exp(η[1])
V1 = TVV1*exp(η[2])
Q = TVQ
V2 = TVV2*exp(η[3])
Vc = V1
Vp = V2
S1 = V1
KE = CL/V1
K12 = Q/V1
K21 = Q/V2
AA = KE+K12+K21
ALPH = (AA+sqrt(AA*AA-4*KE*K21))/2
BETA = (AA-sqrt(AA*AA-4*KE*K21))/2
end
@dynamics Central1Periph1 #a two compartment model
@derived begin
cp = @. 1000*(Central/Vc)
DV ~ @. Normal(cp, ((cp^2*σ_prop)))
end
end
inputDataset = CSV.read("dat.csv")
df = read_pumas(inputDataset, id = :ID, dvs =[:DV], cvs=[:WTKG, :CRCL], evid=:EVID, amt=:AMT,cmt=:CMT, rate=:RATE, time=:TIME)
param = (
θ=([18,14.2,2.13,4.29,1,1,1,1]),
Ω = Diagonal([0.25,0.25,0.25]),
σ_prop = 0.04)
pkres = fit(ped_mod, df, param, Pumas.FOCEI(),
optimize_fn=Pumas.DefaultOptimizeFN(show_trace=true, extended_trace=false))
coeftable(pkres)
pkinfer = infer(pkres)
coeftable(pkinfer)
Error message:
infer(pkres)
Calculating: variance-covariance matrix. Done.
Asymptotic inference results
Successful minimization: true
Likelihood approximation: Pumas.FOCEI
Deviance: 614.17262
Total number of observation records: 133
Number of active observation records: 115
Number of subjects: 35
Error showing value of type Pumas.FittedPumasModelInference{Pumas.FittedPumasModel{PumasModel{ParamSet{NamedTuple{(:θ, :Ω, :σ_prop),Tuple{MvNormal{Float64,PDMats.PDMat{Float64,Array{Float64,2}},Array{Float64,1}},PDiagDomain{PDMats.PDiagMat{Float64,Array{Float64,1}}},RealDomain{Int64,TransformVariables.Infinity{true},Float64}}}},var"#659#714",var"#660#715",var"#661#717",Central1Periph1,var"#662#718",var"#688#744"},Array{Subject{NamedTuple{(:DV,),Tuple{Array{Union{Missing, Float64},1}}},Pumas.ConstantCovar{NamedTuple{(:WTKG, :CRCL),Tuple{Float64,Float64}}},Array{Pumas.Event{Float64,Float64,Float64,Float64,Float64,Float64,Int64},1},Array{Float64,1},Float64},1},Optim.MultivariateOptimizationResults{Optim.BFGS{LineSearches.InitialStatic{Float64},LineSearches.BackTracking{Float64,Int64},Pumas.var"#253#254"{NLSolversBase.OnceDifferentiable{Float64,Array{Float64,1},Array{Float64,1}},Array{Float64,1}},Nothing,Optim.Flat},Float64,Array{Float64,1},Float64,Float64,Array{Optim.OptimizationState{Float64,Optim.BFGS{LineSearches.InitialStatic{Float64},LineSearches.BackTracking{Float64,Int64},Pumas.var"#253#254"{NLSolversBase.OnceDifferentiable{Float64,Array{Float64,1},Array{Float64,1}},Array{Float64,1}},Nothing,Optim.Flat}},1},Bool},Pumas.FOCEI,Array{Array{Float64,1},1},Tuple{},NamedTuple{(:optimize_fn, :constantcoef, :omegas, :ensemblealg),Tuple{Pumas.DefaultOptimizeFN{Nothing,NamedTuple{(:show_trace, :store_trace, :extended_trace, :g_tol, :allow_f_increases),Tuple{Bool,Bool,Bool,Float64,Bool}}},NamedTuple{,Tuple{}},Tuple{},EnsembleSerial}},ParamSet{NamedTuple{(:θ, :Ω, :σ_prop),Tuple{MvNormal{Float64,PDMats.PDMat{Float64,Array{Float64,2}},Array{Float64,1}},PDiagDomain{PDMats.PDiagMat{Float64,Array{Float64,1}}},RealDomain{Int64,TransformVariables.Infinity{true},Float64}}}}},Array{Float64,2},Float64}:
ERROR: MethodError: no method matching tostderrortransform(::MvNormal{Float64,PDMats.PDMat{Float64,Array{Float64,2}},Array{Float64,1}})
Closest candidates are:
tostderrortransform(::ParamSet) at C:\Users\juliapro\JuliaPro_v1.4.2-2\packages\Pumas\NCmSe\src\estimation\transforms.jl:321
tostderrortransform(::ConstDomain) at C:\Users\juliapro\JuliaPro_v1.4.2-2\packages\Pumas\NCmSe\src\estimation\transforms.jl:323
tostderrortransform(::Pumas.Domain) at C:\Users\juliapro\JuliaPro_v1.4.2-2\packages\Pumas\NCmSe\src\estimation\transforms.jl:322
Stacktrace:
[1] map(::typeof(Pumas.tostderrortransform), ::Tuple{MvNormal{Float64,PDMats.PDMat{Float64,Array{Float64,2}},Array{Float64,1}},PDiagDomain{PDMats.PDiagMat{Float64,Array{Float64,1}}},RealDomain{Int64,TransformVariables.Infinity{true},Float64}}) at .\tuple.jl:159
[2] map(::Function, ::NamedTuple{(:θ, :Ω, :σ_prop),Tuple{MvNormal{Float64,PDMats.PDMat{Float64,Array{Float64,2}},Array{Float64,1}},PDiagDomain{PDMats.PDiagMat{Float64,Array{Float64,1}}},RealDomain{Int64,TransformVariables.Infinity{true},Float64}}}) at .\namedtuple.jl:169
[3] tostderrortransform(::ParamSet{NamedTuple{(:θ, :Ω, :σ_prop),Tuple{MvNormal{Float64,PDMats.PDMat{Float64,Array{Float64,2}},Array{Float64,1}},PDiagDomain{PDMats.PDiagMat{Float64,Array{Float64,1}}},RealDomain{Int64,TransformVariables.Infinity{true},Float64}}}}) at C:\Users\juliapro\JuliaPro_v1.4.2-2\packages\Pumas\NCmSe\src\estimation\transforms.jl:321
[4] stderror(::Pumas.FittedPumasModelInference{Pumas.FittedPumasModel{PumasModel{ParamSet{NamedTuple{(:θ, :Ω, :σ_prop),Tuple{MvNormal{Float64,PDMats.PDMat{Float64,Array{Float64,2}},Array{Float64,1}},PDiagDomain{PDMats.PDiagMat{Float64,Array{Float64,1}}},RealDomain{Int64,TransformVariables.Infinity{true},Float64}}}},var"#659#714",var"#660#715",var"#661#717",Central1Periph1,var"#662#718",var"#688#744"},Array{Subject{NamedTuple{(:DV,),Tuple{Array{Union{Missing, Float64},1}}},Pumas.ConstantCovar{NamedTuple{(:WTKG, :CRCL),Tuple{Float64,Float64}}},Array{Pumas.Event{Float64,Float64,Float64,Float64,Float64,Float64,Int64},1},Array{Float64,1},Float64},1},Optim.MultivariateOptimizationResults{Optim.BFGS{LineSearches.InitialStatic{Float64},LineSearches.BackTracking{Float64,Int64},Pumas.var"#253#254"{NLSolversBase.OnceDifferentiable{Float64,Array{Float64,1},Array{Float64,1}},Array{Float64,1}},Nothing,Optim.Flat},Float64,Array{Float64,1},Float64,Float64,Array{Optim.OptimizationState{Float64,Optim.BFGS{LineSearches.InitialStatic{Float64},LineSearches.BackTracking{Float64,Int64},Pumas.var"#253#254"{NLSolversBase.OnceDifferentiable{Float64,Array{Float64,1},Array{Float64,1}},Array{Float64,1}},Nothing,Optim.Flat}},1},Bool},Pumas.FOCEI,Array{Array{Float64,1},1},Tuple{},NamedTuple{(:optimize_fn, :constantcoef, :omegas, :ensemblealg),Tuple{Pumas.DefaultOptimizeFN{Nothing,NamedTuple{(:show_trace, :store_trace, :extended_trace, :g_tol, :allow_f_increases),Tuple{Bool,Bool,Bool,Float64,Bool}}},NamedTuple{,Tuple{}},Tuple{},EnsembleSerial}},ParamSet{NamedTuple{(:θ, :Ω, :σ_prop),Tuple{MvNormal{Float64,PDMats.PDMat{Float64,Array{Float64,2}},Array{Float64,1}},PDiagDomain{PDMats.PDiagMat{Float64,Array{Float64,1}}},RealDomain{Int64,TransformVariables.Infinity{true},Float64}}}}},Array{Float64,2},Float64}) at C:\Users\juliapro\JuliaPro_v1.4.2-2\packages\Pumas\NCmSe\src\estimation\inference.jl:17
[5] coeftable(::Pumas.FittedPumasModelInference{Pumas.FittedPumasModel{PumasModel{ParamSet{NamedTuple{(:θ, :Ω, :σ_prop),Tuple{MvNormal{Float64,PDMats.PDMat{Float64,Array{Float64,2}},Array{Float64,1}},PDiagDomain{PDMats.PDiagMat{Float64,Array{Float64,1}}},RealDomain{Int64,TransformVariables.Infinity{true},Float64}}}},var"#659#714",var"#660#715",var"#661#717",Central1Periph1,var"#662#718",var"#688#744"},Array{Subject{NamedTuple{(:DV,),Tuple{Array{Union{Missing, Float64},1}}},Pumas.ConstantCovar{NamedTuple{(:WTKG, :CRCL),Tuple{Float64,Float64}}},Array{Pumas.Event{Float64,Float64,Float64,Float64,Float64,Float64,Int64},1},Array{Float64,1},Float64},1},Optim.MultivariateOptimizationResults{Optim.BFGS{LineSearches.InitialStatic{Float64},LineSearches.BackTracking{Float64,Int64},Pumas.var"#253#254"{NLSolversBase.OnceDifferentiable{Float64,Array{Float64,1},Array{Float64,1}},Array{Float64,1}},Nothing,Optim.Flat},Float64,Array{Float64,1},Float64,Float64,Array{Optim.OptimizationState{Float64,Optim.BFGS{LineSearches.InitialStatic{Float64},LineSearches.BackTracking{Float64,Int64},Pumas.var"#253#254"{NLSolversBase.OnceDifferentiable{Float64,Array{Float64,1},Array{Float64,1}},Array{Float64,1}},Nothing,Optim.Flat}},1},Bool},Pumas.FOCEI,Array{Array{Float64,1},1},Tuple{},NamedTuple{(:optimize_fn, :constantcoef, :omegas, :ensemblealg),Tuple{Pumas.DefaultOptimizeFN{Nothing,NamedTuple{(:show_trace, :store_trace, :extended_trace, :g_tol, :allow_f_increases),Tuple{Bool,Bool,Bool,Float64,Bool}}},NamedTuple{,Tuple{}},Tuple{},EnsembleSerial}},ParamSet{NamedTuple{(:θ, :Ω, :σ_prop),Tuple{MvNormal{Float64,PDMats.PDMat{Float64,Array{Float64,2}},Array{Float64,1}},PDiagDomain{PDMats.PDiagMat{Float64,Array{Float64,1}}},RealDomain{Int64,TransformVariables.Infinity{true},Float64}}}}},Array{Float64,2},Float64}) at C:\Users\juliapro\JuliaPro_v1.4.2-2\packages\Pumas\NCmSe\src\estimation\show.jl:200
[6] show(::IOContext{REPL.Terminals.TTYTerminal}, ::MIME{Symbol("text/plain")}, ::Pumas.FittedPumasModelInference{Pumas.FittedPumasModel{PumasModel{ParamSet{NamedTuple{(:θ, :Ω, :σ_prop),Tuple{MvNormal{Float64,PDMats.PDMat{Float64,Array{Float64,2}},Array{Float64,1}},PDiagDomain{PDMats.PDiagMat{Float64,Array{Float64,1}}},RealDomain{Int64,TransformVariables.Infinity{true},Float64}}}},var"#659#714",var"#660#715",var"#661#717",Central1Periph1,var"#662#718",var"#688#744"},Array{Subject{NamedTuple{(:DV,),Tuple{Array{Union{Missing, Float64},1}}},Pumas.ConstantCovar{NamedTuple{(:WTKG, :CRCL),Tuple{Float64,Float64}}},Array{Pumas.Event{Float64,Float64,Float64,Float64,Float64,Float64,Int64},1},Array{Float64,1},Float64},1},Optim.MultivariateOptimizationResults{Optim.BFGS{LineSearches.InitialStatic{Float64},LineSearches.BackTracking{Float64,Int64},Pumas.var"#253#254"{NLSolversBase.OnceDifferentiable{Float64,Array{Float64,1},Array{Float64,1}},Array{Float64,1}},Nothing,Optim.Flat},Float64,Array{Float64,1},Float64,Float64,Array{Optim.OptimizationState{Float64,Optim.BFGS{LineSearches.InitialStatic{Float64},LineSearches.BackTracking{Float64,Int64},Pumas.var"#253#254"{NLSolversBase.OnceDifferentiable{Float64,Array{Float64,1},Array{Float64,1}},Array{Float64,1}},Nothing,Optim.Flat}},1},Bool},Pumas.FOCEI,Array{Array{Float64,1},1},Tuple{},NamedTuple{(:optimize_fn, :constantcoef, :omegas, :ensemblealg),Tuple{Pumas.DefaultOptimizeFN{Nothing,NamedTuple{(:show_trace, :store_trace, :extended_trace, :g_tol, :allow_f_increases),Tuple{Bool,Bool,Bool,Float64,Bool}}},NamedTuple{,Tuple{}},Tuple{},EnsembleSerial}},ParamSet{NamedTuple{(:θ, :Ω, :σ_prop),Tuple{MvNormal{Float64,PDMats.PDMat{Float64,Array{Float64,2}},Array{Float64,1}},PDiagDomain{PDMats.PDiagMat{Float64,Array{Float64,1}}},RealDomain{Int64,TransformVariables.Infinity{true},Float64}}}}},Array{Float64,2},Float64}) at C:\Users\.juliapro\JuliaPro_v1.4.2-2\packages\Pumas\NCmSe\src\estimation\show.jl:237
[7] display(::REPL.REPLDisplay, ::MIME{Symbol("text/plain")}, ::Any) at C:\Users\julia\AppData\Local\Julia-1.4.2\share\julia\stdlib\v1.4\REPL\src\REPL.jl:137
[8] display(::REPL.REPLDisplay, ::Any) at C:\Users\julia\AppData\Local\Julia-1.4.2\share\julia\stdlib\v1.4\REPL\src\REPL.jl:141
[9] display(::Any) at .\multimedia.jl:323
[10] #invokelatest#1 at .\essentials.jl:712 [inlined]
[11] invokelatest at .\essentials.jl:711 [inlined]
[12] print_response(::IO, ::Any, ::Bool, ::Bool, ::Any) at C:\Users\julia\AppData\Local\Julia-1.4.2\share\julia\stdlib\v1.4\REPL\src\REPL.jl:161
[13] print_response(::REPL.AbstractREPL, ::Any, ::Bool, ::Bool) at C:\Users\julia\AppData\Local\Julia-1.4.2\share\julia\stdlib\v1.4\REPL\src\REPL.jl:146
[14] (::REPL.var"#do_respond#38"{Bool,Atom.var"#250#251",REPL.LineEditREPL,REPL.LineEdit.Prompt})(::Any, ::Any, ::Any) at C:\Users\julia\AppData\Local\Julia-1.4.2\share\julia\stdlib\v1.4\REPL\src\REPL.jl:729
[15] #invokelatest#1 at .\essentials.jl:712 [inlined]
[16] invokelatest at .\essentials.jl:711 [inlined]
[17] run_interface(::REPL.Terminals.TextTerminal, ::REPL.LineEdit.ModalInterface, ::REPL.LineEdit.MIState) at C:\Users\julia\AppData\Local\Julia-1.4.2\share\julia\stdlib\v1.4\REPL\src\LineEdit.jl:2354
[18] run_frontend(::REPL.LineEditREPL, ::REPL.REPLBackendRef) at C:\Users\julia\AppData\Local\Julia-1.4.2\share\julia\stdlib\v1.4\REPL\src\REPL.jl:1055
[19] run_repl(::REPL.AbstractREPL, ::Any) at C:\Users\julia\AppData\Local\Julia-1.4.2\share\julia\stdlib\v1.4\REPL\src\REPL.jl:206
[20] (::Base.var"#764#766"{Bool,Bool,Bool,Bool})(::Module) at .\client.jl:383
[21] #invokelatest#1 at .\essentials.jl:712 [inlined]
[22] invokelatest at .\essentials.jl:711 [inlined]
[23] run_main_repl(::Bool, ::Bool, ::Bool, ::Bool, ::Bool) at .\client.jl:367
[24] exec_options(::Base.JLOptions) at .\client.jl:305
[25] _start() at .\client.jl:484
Thanks!
Anqi