Hello,
I have specified a model in Turing.jl as follows:
using Turing
@model function LGDS(x::AbstractArray, prob, params::Dict, t_int)
# prior distributions
σ ~ InverseGamma(2, 3)
lC ~ MvNormal(params[:μ_C], params[:Σ_C])
lR ~ MvNormal(params[:μ_R], params[:Σ_R])
lA ~ MvNormal(params[:μ_A], params[:Σ_A])
p = [lC; lR; lA]
# remake the problem with the sampled parameter values
prob_samp = remake(prob; p = p)
# solve the ODE
T_ode = solve(prob_samp, Tsit5(); save_idxs=1, verbose=false)
if !(SciMLBase.successful_retcode(T_ode.retcode))
return
end
# time points corresponding to observations `x`
x_est = T_ode(time)
x ~ MvNormal(x_est.u, σ^2 * I)
return nothing
end
# instantiate model
input_data = data[!, :T_i]
model = LGDS(input_data, prob, prior_params, Δt)
# sample independent chains
n_chains = 3
chain = sample(model, NUTS(0.65), MCMCSerial(), 30, n_chains; progress=true)
The output of Turing.jl looks like this:
point_est = mean(chain[:, :, 3])
Mean
parameters mean
Symbol Float64
σ 11.8814
lC[1] 2.1847
lC[2] 1.0088
lC[3] -0.0872
lR[1] -1.4498
lR[2] -0.4706
lR[3] 1.6218
lA[1] 0.6406
lA[2] 0.9099
The problem is now, how can I uniquely identify the parameters in the final p
at the end of the estimation process?
It’s essentially similar to this problem.
I tried this:
prob_final = remake(prob; p=p)
prob_final.ps[sys.lC_i]
But that will give:
ArgumentError: invalid index: ModelingToolkit.ParameterIndex …