Hi,
It’s been a long time -
I have a fitting error that I can’t get rid off -
I have gone through my data and I don’t see anything wrong with it - the model will simulate quite well, but when I try to fit to my dataset it breaks almost immediatly -
There is an error trying to access an Array at index 1 for a an Array of size 0, but I don’t see anything in the data that could explain that.
Could you point me at what an error like this may be pointing so I can investigate and try to fix?
Thanks,
Ale-
As always happy to share model and data if needed.
BoundsError: attempt to access 0-element Array{Float64,1} at index [1]
Stacktrace:
[1] getindex at .\array.jl:728 [inlined]
[2] #solve_tr_subproblem!#36(::Float64, ::Int64, ::typeof(Optim.solve_tr_subproblem!), ::Array{Float64,1}, ::Array{Float64,2}, ::Float64, ::Array{Float64,1}) at C:\Users\awolf-yadlin\.juliapro\JuliaPro_v1.2.0-2\packages\Optim\cJRng\src\multivariate\solvers\second_order\newton_trust_region.jl:105
[3] solve_tr_subproblem! at C:\Users\awolf-yadlin\.juliapro\JuliaPro_v1.2.0-2\packages\Optim\cJRng\src\multivariate\solvers\second_order\newton_trust_region.jl:94 [inlined]
[4] update_state!(::NLSolversBase.TwiceDifferentiable{Float64,Array{Float64,1},Array{Float64,2},Array{Float64,1}}, ::Optim.NewtonTrustRegionState{Array{Float64,1},Float64,Array{Float64,1}}, ::Optim.NewtonTrustRegion{Float64}) at C:\Users\awolf-yadlin\.juliapro\JuliaPro_v1.2.0-2\packages\Optim\cJRng\src\multivariate\solvers\second_order\newton_trust_region.jl:314
[5] optimize(::NLSolversBase.TwiceDifferentiable{Float64,Array{Float64,1},Array{Float64,2},Array{Float64,1}}, ::Array{Float64,1}, ::Optim.NewtonTrustRegion{Float64}, ::Optim.Options{Float64,Nothing}, ::Optim.NewtonTrustRegionState{Array{Float64,1},Float64,Array{Float64,1}}) at C:\Users\awolf-yadlin\.juliapro\JuliaPro_v1.2.0-2\packages\Optim\cJRng\src\multivariate\optimize\optimize.jl:57
[6] optimize at C:\Users\awolf-yadlin\.juliapro\JuliaPro_v1.2.0-2\packages\Optim\cJRng\src\multivariate\optimize\optimize.jl:33 [inlined]
[7] #_orth_empirical_bayes!#145(::Base.Iterators.Pairs{Symbol,Any,Tuple{Symbol,Symbol},NamedTuple{(:maxiters, :alg),Tuple{Int64,Rodas5{0,false,DefaultLinSolve,DataType}}}}, ::typeof(Pumas._orth_empirical_bayes!), ::Array{Float64,1}, ::PumasModel{ParamSet{NamedTuple{(:θ, :Ω, :σ_prop),Tuple{VectorDomain{Array{Float64,1},Array{TransformVariables.Infinity{true},1},Array{Float64,1}},PDiagDomain{PDMats.PDiagMat{Float64,Array{Float64,1}}},RealDomain{Float64,TransformVariables.Infinity{true},Float64}}}},getfield(Main, Symbol("##437#444")),getfield(Main, Symbol("##438#445")),getfield(Main, Symbol("##439#446")),ODEProblem{Nothing,Tuple{Nothing,Nothing},false,Nothing,ODEFunction{false,getfield(Main, Symbol("##440#447")),UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{,Tuple{}}},DiffEqBase.StandardODEProblem},getfield(Main, Symbol("##442#449")),getfield(Main, Symbol("##443#450"))}, ::Subject{NamedTuple{(:RO,),Tuple{Array{Union{Missing, Float64},1}}},NamedTuple{(:CLS, :V1S, :kshd),Tuple{Float64,Float64,Float64}},Array{Pumas.Event{Float64,Float64,Float64,Float64,Float64,Float64,Int64},1},Array{Float64,1}}, ::NamedTuple{(:θ, :Ω, :σ_prop),Tuple{Array{Float64,1},PDMats.PDiagMat{Float64,Array{Float64,1}},Float64}}, ::Pumas.FOCEI) at C:\Users\awolf-yadlin\.juliapro\JuliaPro_v1.2.0-2\packages\Pumas\Twdge\src\estimation\likelihoods.jl:248
[8] mapfoldl_impl(::getfield(Pumas, Symbol("##219#225")){NamedTuple{(:θ, :Ω, :σ_prop),Tuple{Array{Float64,1},PDMats.PDiagMat{Float64,Array{Float64,1}},Float64}},Base.Iterators.Pairs{Symbol,Any,Tuple{Symbol,Symbol},NamedTuple{(:maxiters, :alg),Tuple{Int64,Rodas5{0,false,DefaultLinSolve,DataType}}}},PumasModel{ParamSet{NamedTuple{(:θ, :Ω, :σ_prop),Tuple{VectorDomain{Array{Float64,1},Array{TransformVariables.Infinity{true},1},Array{Float64,1}},PDiagDomain{PDMats.PDiagMat{Float64,Array{Float64,1}}},RealDomain{Float64,TransformVariables.Infinity{true},Float64}}}},getfield(Main, Symbol("##437#444")),getfield(Main, Symbol("##438#445")),getfield(Main, Symbol("##439#446")),ODEProblem{Nothing,Tuple{Nothing,Nothing},false,Nothing,ODEFunction{false,getfield(Main, Symbol("##440#447")),UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{,Tuple{}}},DiffEqBase.StandardODEProblem},getfield(Main, Symbol("##442#449")),getfield(Main, Symbol("##443#450"))},Pumas.FOCEI,Tuple{}}, ::typeof(Base.add_sum), ::NamedTuple{(:init,),Tuple{Float64}}, ::Base.Iterators.Zip{Tuple{Array{Subject{NamedTuple{(:RO,),Tuple{Array{Union{Missing, Float64},1}}},NamedTuple{(:CLS, :V1S, :kshd),Tuple{Float64,Float64,Float64}},Array{Pumas.Event{Float64,Float64,Float64,Float64,Float64,Float64,Int64},1},Array{Float64,1}},1},Array{Array{Float64,1},1},Array{Array{Float64,1},1}}}, ::Tuple{Int64,Int64,Int64}) at .\none:0
[9] mapfoldl_impl(::Function, ::Function, ::NamedTuple{,Tuple{}}, ::Base.Iterators.Zip{Tuple{Array{Subject{NamedTuple{(:RO,),Tuple{Array{Union{Missing, Float64},1}}},NamedTuple{(:CLS, :V1S, :kshd),Tuple{Float64,Float64,Float64}},Array{Pumas.Event{Float64,Float64,Float64,Float64,Float64,Float64,Int64},1},Array{Float64,1}},1},Array{Array{Float64,1},1},Array{Array{Float64,1},1}}}) at .\reduce.jl:61
[10] #mapfoldl#188 at .\reduce.jl:72 [inlined]
[11] mapfoldl at .\reduce.jl:72 [inlined]
[12] #mapreduce#192 at .\reduce.jl:208 [inlined]
[13] mapreduce at .\reduce.jl:208 [inlined]
[14] sum(::Function, ::Base.Iterators.Zip{Tuple{Array{Subject{NamedTuple{(:RO,),Tuple{Array{Union{Missing, Float64},1}}},NamedTuple{(:CLS, :V1S, :kshd),Tuple{Float64,Float64,Float64}},Array{Pumas.Event{Float64,Float64,Float64,Float64,Float64,Float64,Int64},1},Array{Float64,1}},1},Array{Array{Float64,1},1},Array{Array{Float64,1},1}}}) at .\reduce.jl:403
[15] (::getfield(Pumas, Symbol("##218#224")){Base.Iterators.Pairs{Symbol,Any,Tuple{Symbol,Symbol},NamedTuple{(:maxiters, :alg),Tuple{Int64,Rodas5{0,false,DefaultLinSolve,DataType}}}},PumasModel{ParamSet{NamedTuple{(:θ, :Ω, :σ_prop),Tuple{VectorDomain{Array{Float64,1},Array{TransformVariables.Infinity{true},1},Array{Float64,1}},PDiagDomain{PDMats.PDiagMat{Float64,Array{Float64,1}}},RealDomain{Float64,TransformVariables.Infinity{true},Float64}}}},getfield(Main, Symbol("##437#444")),getfield(Main, Symbol("##438#445")),getfield(Main, Symbol("##439#446")),ODEProblem{Nothing,Tuple{Nothing,Nothing},false,Nothing,ODEFunction{false,getfield(Main, Symbol("##440#447")),UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{,Tuple{}}},DiffEqBase.StandardODEProblem},getfield(Main, Symbol("##442#449")),getfield(Main, Symbol("##443#450"))},Array{Subject{NamedTuple{(:RO,),Tuple{Array{Union{Missing, Float64},1}}},NamedTuple{(:CLS, :V1S, :kshd),Tuple{Float64,Float64,Float64}},Array{Pumas.Event{Float64,Float64,Float64,Float64,Float64,Float64,Int64},1},Array{Float64,1}},1},Pumas.FOCEI,Tuple{}})(::Float64, ::Array{Float64,1}, ::Array{Float64,1}) at C:\Users\awolf-yadlin\.juliapro\JuliaPro_v1.2.0-2\packages\Pumas\Twdge\src\estimation\likelihoods.jl:1074
[16] (::getfield(NLSolversBase, Symbol("##61#62")){NLSolversBase.InplaceObjective{Nothing,getfield(Pumas, Symbol("##218#224")){Base.Iterators.Pairs{Symbol,Any,Tuple{Symbol,Symbol},NamedTuple{(:maxiters, :alg),Tuple{Int64,Rodas5{0,false,DefaultLinSolve,DataType}}}},PumasModel{ParamSet{NamedTuple{(:θ, :Ω, :σ_prop),Tuple{VectorDomain{Array{Float64,1},Array{TransformVariables.Infinity{true},1},Array{Float64,1}},PDiagDomain{PDMats.PDiagMat{Float64,Array{Float64,1}}},RealDomain{Float64,TransformVariables.Infinity{true},Float64}}}},getfield(Main, Symbol("##437#444")),getfield(Main, Symbol("##438#445")),getfield(Main, Symbol("##439#446")),ODEProblem{Nothing,Tuple{Nothing,Nothing},false,Nothing,ODEFunction{false,getfield(Main, Symbol("##440#447")),UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{,Tuple{}}},DiffEqBase.StandardODEProblem},getfield(Main, Symbol("##442#449")),getfield(Main, Symbol("##443#450"))},Array{Subject{NamedTuple{(:RO,),Tuple{Array{Union{Missing, Float64},1}}},NamedTuple{(:CLS, :V1S, :kshd),Tuple{Float64,Float64,Float64}},Array{Pumas.Event{Float64,Float64,Float64,Float64,Float64,Float64,Int64},1},Array{Float64,1}},1},Pumas.FOCEI,Tuple{}},Nothing,Nothing,Nothing},Float64})(::Array{Float64,1}, ::Array{Float64,1}) at C:\Users\awolf-yadlin\.juliapro\JuliaPro_v1.2.0-2\packages\NLSolversBase\mGaJg\src\objective_types\incomplete.jl:45
[17] value_gradient!!(::NLSolversBase.OnceDifferentiable{Float64,Array{Float64,1},Array{Float64,1}}, ::Array{Float64,1}) at C:\Users\awolf-yadlin\.juliapro\JuliaPro_v1.2.0-2\packages\NLSolversBase\mGaJg\src\interface.jl:82
[18] initial_state(::Optim.BFGS{LineSearches.InitialStatic{Float64},LineSearches.BackTracking{Float64,Int64},getfield(Pumas, Symbol("##211#212")){NLSolversBase.OnceDifferentiable{Float64,Array{Float64,1},Array{Float64,1}},Array{Float64,1}},Nothing,Optim.Flat}, ::Optim.Options{Float64,getfield(Pumas, Symbol("##217#223"))}, ::NLSolversBase.OnceDifferentiable{Float64,Array{Float64,1},Array{Float64,1}}, ::Array{Float64,1}) at C:\Users\awolf-yadlin\.juliapro\JuliaPro_v1.2.0-2\packages\Optim\cJRng\src\multivariate\solvers\first_order\bfgs.jl:66
[19] optimize(::NLSolversBase.OnceDifferentiable{Float64,Array{Float64,1},Array{Float64,1}}, ::Array{Float64,1}, ::Optim.BFGS{LineSearches.InitialStatic{Float64},LineSearches.BackTracking{Float64,Int64},getfield(Pumas, Symbol("##211#212")){NLSolversBase.OnceDifferentiable{Float64,Array{Float64,1},Array{Float64,1}},Array{Float64,1}},Nothing,Optim.Flat}, ::Optim.Options{Float64,getfield(Pumas, Symbol("##217#223"))}) at C:\Users\awolf-yadlin\.juliapro\JuliaPro_v1.2.0-2\packages\Optim\cJRng\src\multivariate\optimize\optimize.jl:33
[20] (::Pumas.DefaultOptimizeFN{Nothing,NamedTuple{(:show_trace, :store_trace, :extended_trace, :g_tol, :allow_f_increases),Tuple{Bool,Bool,Bool,Float64,Bool}}})(::NLSolversBase.OnceDifferentiable{Float64,Array{Float64,1},Array{Float64,1}}, ::Array{Float64,1}, ::Function) at C:\Users\awolf-yadlin\.juliapro\JuliaPro_v1.2.0-2\packages\Pumas\Twdge\src\estimation\likelihoods.jl:983
[21] #fit#214(::Pumas.DefaultOptimizeFN{Nothing,NamedTuple{(:show_trace, :store_trace, :extended_trace, :g_tol, :allow_f_increases),Tuple{Bool,Bool,Bool,Float64,Bool}}}, ::NamedTuple{,Tuple{}}, ::Base.Iterators.Pairs{Symbol,Any,Tuple{Symbol,Symbol},NamedTuple{(:maxiters, :alg),Tuple{Int64,Rodas5{0,false,DefaultLinSolve,DataType}}}}, ::typeof(fit), ::PumasModel{ParamSet{NamedTuple{(:θ, :Ω, :σ_prop),Tuple{VectorDomain{Array{Float64,1},Array{TransformVariables.Infinity{true},1},Array{Float64,1}},PDiagDomain{PDMats.PDiagMat{Float64,Array{Float64,1}}},RealDomain{Float64,TransformVariables.Infinity{true},Float64}}}},getfield(Main, Symbol("##437#444")),getfield(Main, Symbol("##438#445")),getfield(Main, Symbol("##439#446")),ODEProblem{Nothing,Tuple{Nothing,Nothing},false,Nothing,ODEFunction{false,getfield(Main, Symbol("##440#447")),UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{,Tuple{}}},DiffEqBase.StandardODEProblem},getfield(Main, Symbol("##442#449")),getfield(Main, Symbol("##443#450"))}, ::Array{Subject{NamedTuple{(:RO,),Tuple{Array{Union{Missing, Float64},1}}},NamedTuple{(:CLS, :V1S, :kshd),Tuple{Float64,Float64,Float64}},Array{Pumas.Event{Float64,Float64,Float64,Float64,Float64,Float64,Int64},1},Array{Float64,1}},1}, ::NamedTuple{(:θ, :Ω, :σ_prop),Tuple{Array{Float64,1},PDMats.PDiagMat{Float64,Array{Float64,1}},Float64}}, ::Pumas.FOCEI) at C:\Users\awolf-yadlin\.juliapro\JuliaPro_v1.2.0-2\packages\Pumas\Twdge\src\estimation\likelihoods.jl:1097
[22] (::getfield(StatsBase, Symbol("#kw##fit")))(::NamedTuple{(:maxiters, :alg),Tuple{Int64,Rodas5{0,false,DefaultLinSolve,DataType}}}, ::typeof(fit), ::PumasModel{ParamSet{NamedTuple{(:θ, :Ω, :σ_prop),Tuple{VectorDomain{Array{Float64,1},Array{TransformVariables.Infinity{true},1},Array{Float64,1}},PDiagDomain{PDMats.PDiagMat{Float64,Array{Float64,1}}},RealDomain{Float64,TransformVariables.Infinity{true},Float64}}}},getfield(Main, Symbol("##437#444")),getfield(Main, Symbol("##438#445")),getfield(Main, Symbol("##439#446")),ODEProblem{Nothing,Tuple{Nothing,Nothing},false,Nothing,ODEFunction{false,getfield(Main, Symbol("##440#447")),UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{,Tuple{}}},DiffEqBase.StandardODEProblem},getfield(Main, Symbol("##442#449")),getfield(Main, Symbol("##443#450"))}, ::Array{Subject{NamedTuple{(:RO,),Tuple{Array{Union{Missing, Float64},1}}},NamedTuple{(:CLS, :V1S, :kshd),Tuple{Float64,Float64,Float64}},Array{Pumas.Event{Float64,Float64,Float64,Float64,Float64,Float64,Int64},1},Array{Float64,1}},1}, ::NamedTuple{(:θ, :Ω, :σ_prop),Tuple{Array{Float64,1},PDMats.PDiagMat{Float64,Array{Float64,1}},Float64}}, ::Pumas.FOCEI) at .\none:0
[23] top-level scope at util.jl:156
[24] top-level scope at In[281]:2
Ale