Hi all,
I am new to Turing and wanted to play on a toy example with a multiple response regression. Here is the code. Any help will be greatly appreciated.
#— Code started here
using Distributions, LinearAlgebra
using DistributionsAD, AdvancedVI
using Random, PDMats
using Turing
using Turing: Variational
Random.seed!(42);
@model function MultVar2(X, Y) #, ::Type{T}=Vector{Float64}) where {T} = begin
n, q = size(Y)
_, p = size(X)
ν0 = q + 1.
#-- Lambda
#
Λ ~ MvNormal(zeros(p), 10.)
#end
# Variancce Components
Σ ~ InverseWishart(ν0, PDMat(Matrix{Float64}(I,q,q)))
# C matrix
C ~ MatrixNormal(zeros(p,q), PDMat(diagm(exp.(Λ))) , Σ)
#--- Likelihood
mu = X*C
Y ~ MatrixNormal(mu, Matrix{Float64}(I, n, n), Σ)
end;
#-- Simulate data
n= 30
p = 5
q = 3
C= zeros(p, q)
C[1:2,1:q] = 2.0 .+ randn(2,3)
X = randn(n, p)
Y = X*C + randn(n,q)
n, q = size(Y)
_, p = size(X)
ν0 = p+1.
#-- Sample
c6 = sample(MultVar2(X, Y), NUTS(0.65), 1000)
when I run this I get the following error
type InverseWishart has no field c0
getproperty(::InverseWishart{Float64,PDMat{Float64,Array{Float64,2}}}, ::Symbol) at Base.jl:33
getlogp(::InverseWishart{Float64,PDMat{Float64,Array{Float64,2}}}, ::Cholesky{Float64,Array{Float64,2}}, ::Array{Float64,2}) at Bijectors.jl:240
pd_logpdf_with_trans(::InverseWishart{Float64,PDMat{Float64,Array{Float64,2}}}, ::Array{Float64,2}, ::Bool) at Bijectors.jl:221
logpdf_with_trans(::InverseWishart{Float64,PDMat{Float64,Array{Float64,2}}}, ::Array{Float64,2}, ::Bool) at Bijectors.jl:122
assume(::Random._GLOBAL_RNG, ::DynamicPPL.SampleFromPrior, ::InverseWishart{Float64,PDMat{Float64,Array{Float64,2}}}, ::DynamicPPL.VarName{:Σ,Tuple{}}, ::DynamicPPL.ThreadSafeVarInfo{DynamicPPL.VarInfo{DynamicPPL.Metadata{Dict{DynamicPPL.VarName,Int64},Array{Distribution,1},Array{DynamicPPL.VarName,1},Array{Real,1},Array{Set{DynamicPPL.Selector},1}},Float64},Array{Base.RefValue{Float64},1}}) at context_implementations.jl:142
_tilde at context_implementations.jl:59 [inlined]
tilde at context_implementations.jl:23 [inlined]
tilde_assume(::Random._GLOBAL_RNG, ::DynamicPPL.DefaultContext, ::DynamicPPL.SampleFromPrior, ::InverseWishart{Float64,PDMat{Float64,Array{Float64,2}}}, ::DynamicPPL.VarName{:Σ,Tuple{}}, ::Tuple{}, ::DynamicPPL.ThreadSafeVarInfo{DynamicPPL.VarInfo{DynamicPPL.Metadata{Dict{DynamicPPL.VarName,Int64},Array{Distribution,1},Array{DynamicPPL.VarName,1},Array{Real,1},Array{Set{DynamicPPL.Selector},1}},Float64},Array{Base.RefValue{Float64},1}}) at context_implementations.jl:52
macro expansion at VB_Turing.jl:41 [inlined]
##evaluator#371(::Random._GLOBAL_RNG, ::DynamicPPL.Model{var"###evaluator#371",(:X, :Y),Tuple{Array{Float64,2},Array{Float64,2}},(),DynamicPPL.ModelGen{var"###generator#372",(:X, :Y),(),Tuple{}}}, ::DynamicPPL.ThreadSafeVarInfo{DynamicPPL.VarInfo{DynamicPPL.Metadata{Dict{DynamicPPL.VarName,Int64},Array{Distribution,1},Array{DynamicPPL.VarName,1},Array{Real,1},Array{Set{DynamicPPL.Selector},1}},Float64},Array{Base.RefValue{Float64},1}}, ::DynamicPPL.SampleFromPrior, ::DynamicPPL.DefaultContext) at compiler.jl:356
evaluate_threadsafe(::Random._GLOBAL_RNG, ::DynamicPPL.Model{var"###evaluator#371",(:X, :Y),Tuple{Array{Float64,2},Array{Float64,2}},(),DynamicPPL.ModelGen{var"###generator#372",(:X, :Y),(),Tuple{}}}, ::DynamicPPL.VarInfo{DynamicPPL.Metadata{Dict{DynamicPPL.VarName,Int64},Array{Distribution,1},Array{DynamicPPL.VarName,1},Array{Real,1},Array{Set{DynamicPPL.Selector},1}},Float64}, ::DynamicPPL.SampleFromPrior, ::DynamicPPL.DefaultContext) at model.jl:177
Model at model.jl:138 [inlined]
Model at model.jl:126 [inlined]
VarInfo at varinfo.jl:110 [inlined]
VarInfo at varinfo.jl:109 [inlined]
DynamicPPL.Sampler(::NUTS{Turing.Core.ForwardDiffAD{40},(),AdvancedHMC.DiagEuclideanMetric}, ::DynamicPPL.Model{var"###evaluator#371",(:X, :Y),Tuple{Array{Float64,2},Array{Float64,2}},(),DynamicPPL.ModelGen{var"###generator#372",(:X, :Y),(),Tuple{}}}, ::DynamicPPL.Selector) at hmc.jl:378
Sampler at hmc.jl:376 [inlined]
sample(::Random._GLOBAL_RNG, ::DynamicPPL.Model{var"###evaluator#371",(:X, :Y),Tuple{Array{Float64,2},Array{Float64,2}},(),DynamicPPL.ModelGen{var"###generator#372",(:X, :Y),(),Tuple{}}}, ::NUTS{Turing.Core.ForwardDiffAD{40},(),AdvancedHMC.DiagEuclideanMetric}, ::Int64; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at Inference.jl:163
sample at Inference.jl:163 [inlined]
#sample#1 at Inference.jl:153 [inlined]
sample(::DynamicPPL.Model{var"###evaluator#371",(:X, :Y),Tuple{Array{Float64,2},Array{Float64,2}},(),DynamicPPL.ModelGen{var"###generator#372",(:X, :Y),(),Tuple{}}}, ::NUTS{Turing.Core.ForwardDiffAD{40},(),AdvancedHMC.DiagEuclideanMetric}, ::Int64) at Inference.jl:153
top-level scope at VB_Turing.jl:53