using Mamba using Pandas # Data FP = open(raw"./data-salary.txt") Data = read_csv(FP) close(FP) Data # Model Definition model = Model( y = Stochastic(1, (a, b, x, sigma) -> MvNormal(a + b*x, sigma), false ), b = Stochastic(() -> Normal(0, 100)), a = Stochastic(() -> Normal(0, 100)), sigma = Stochastic(() -> Rayleigh(100)) ) ## Sampling Scheme scheme = [NUTS(:a), NUTS(:b),Slice(:sigma,10)] setsamplers!(model, scheme) # Data Conversion Dat = Dict{Symbol, Any}( :x => Array(Data[:X]), :y => Array(Data[:Y]) ) # Initial Values inits = [ Dict{Symbol, Any}( :y => Dat[:y], :a => rand(Normal(0, 1)), :b => rand(Normal(0, 1)), :sigma => rand(Rayleigh(1)) ) for i in 1:4 ] ## MCMC Simulations sim = mcmc(model, Dat, inits, 4000, burnin=2000, thin=1, chains=4) Mamba.describe(sim) p = Mamba.plot(sim) draw(p) using Plots gr() Plots.plot(Dat[:x],Dat[:y],st=:scatter)