hey guys i’m getting this error while running my model in mamba:
‘LoadError: ArgumentError: matrix is not symmetric/Hermitian. This error can be avoided by calling cholfact(Hermitian(A)) which will ignore either the upper or lower triangle of the matrix.’
i can’t crack it on my own, please help.
here is the code:
using Mamba
using Distributions
##Data
data=Dict{Symbol,Any}(
:z => [1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0,
0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0,
0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0,
1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0],
:y => [0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0,
1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0,
1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0,
1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0,
1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0],
:x => [1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0,
1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0,
1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0,
1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0,
1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0]
)
data[:sig] = eye(5)
data[:J] = 20
data[:I] = 5
##Model
model=Model(
z = Stochastic(2,
(b, x, y) ->
UnivariateDistribution[
Bernoulli(1+exp(transpose(b[j])*(y[i, j]-x[i, j])))^(-1)
for i in 1:I, j in 1:J
],
false
),
b=Stochastic(1,
(mu, sig) ->
MultivariateDistribution[
MultivariateNormal(mu,sig)
for j in 1:J
]
),
mu=Stochastic(1,
(mu0, sig0)->
MultivariateNormal(mu0, sig0)
),
mu0=Stochastic(1,
()->Uniform(0,1),
false
),
sig0=Stochastic(2,
()->Uniform(0,1),
false
)
)
##Initial Values
inits=[
Dict(:z => data[:z], :b =>zeros(5,10), :mu => rand(5), :mu0 => rand(5), :sig0 => rand(5,5)),
Dict(:z => data[:z], :b =>rand(5,10), :mu => ones(5), :mu0 => ones(5), :sig0 => rand(5,5))
]
#Sample Scheme
scheme = [AMWG(:mu,1.0), AMWG(:b,1.0)]
setsamplers!(model,scheme)
##MCMC simulation
sim= mcmc(model, data, inits, 10000, burnin=2500, thin=2, chains=2)
describe(sim)
i actually have no idea what i am doing in the sample scheme section.