Here is my full code, based on a Turing tutorial.
using Turing, Turing.RandomMeasures
using LinearAlgebra, Distributions
using Plots, Random, CSV, DataFrames
share_1 = rand(Uniform(), 100)
share_2 = 1 .- share_1
shares = hcat(share_1, share_2)
@model function infiniteGMM(x)
# Hyper-parameters, i.e. concentration parameter and parameters of H.
N = size(x)[1]
D = size(x)[2]
α = 10.0
rpm = DirichletProcess(α) # Define random measure, e.g. Dirichlet process
Hv = [Exponential(10 * el) for el in mean(x, dims=1)]
H = Exponential(5)
z = tzeros(Int, N)
μ = tzeros(Float64, D, 0)
for i in 1:N
# Number of clusters.
K = maximum(z)
nk = Vector{Int}(map(k -> sum(z .== k), 1:K))
# Draw the latent assignment.
z[i] ~ ChineseRestaurantProcess(rpm, nk)
# Create a new cluster?
if z[i] > K
μ = hcat(μ, ones(D))
# Draw location of new cluster.
for j in 1:size(μ)[1]
μ[j, z[i]] ~ H
end
end
# Draw observation.
x[i, :] ~ Dirichlet(μ[:, z[i]])
end
end
# MCMC sampling
Random.seed!(2)
iterations = 100
model_fun = infiniteGMM(shares);
chain = sample(model_fun, SMC(), iterations);
I get this error on the final line:
ERROR: MethodError: no method matching translate!!(::Core.SSAValue, ::Tuple{Symbol}, ::Vector{Any}, ::Bool, ::Core.CodeInfo)
I’m very new to Julia and Turing, I don’t know where to start with this one.