{"action":"reopened","issue":{"url":"https://api.github.com/repos/brian-j-smith/Mamba.jl/issues/104","repository_url":"https://api.github.com/repos/brian-j-smith/Mamba.jl","labels_url":"https://api.github.com/repos/brian-j-smith/Mamba.jl/issues/104/labels{/name}","comments_url":"https://api.github.com/repos/brian-j-smith/Mamba.jl/issues/104/comments","events_url":"https://api.github.com/repos/brian-j-smith/Mamba.jl/issues/104/events","html_url":"https://github.com/brian-j-smith/Mamba.jl/issues/104","id":179488577,"number":104,"title":"Learning to use the Mamba package  (also posted on stackoverflow)","user":{"login":"ngiann","id":6739784,"avatar_url":"https://avatars.githubusercontent.com/u/6739784?v=3","gravatar_id":"","url":"https://api.github.com/users/ngiann","html_url":"https://github.com/ngiann","followers_url":"https://api.github.com/users/ngiann/followers","following_url":"https://api.github.com/users/ngiann/following{/other_user}","gists_url":"https://api.github.com/users/ngiann/gists{/gist_id}","starred_url":"https://api.github.com/users/ngiann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ngiann/subscriptions","organizations_url":"https://api.github.com/users/ngiann/orgs","repos_url":"https://api.github.com/users/ngiann/repos","events_url":"https://api.github.com/users/ngiann/events{/privacy}","received_events_url":"https://api.github.com/users/ngiann/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-09-27T13:10:35Z","updated_at":"2016-09-28T10:29:39Z","closed_at":null,"body":"Dear all,\r\n\r\nI am sorry to be posting here, as far as I understand the forum here is intended for development issues mostly.\r\n\r\nI am trying to learn how to use the Mamba package in Julia for doing Bayesian inference. Though the package is great, as a beginner I find the documentation a little difficult to follow. Hence I am trying to figure out how to implement some very simple examples.\r\n\r\n**What I have tried**\r\n\r\nI implemented an example for doing Bayesian inference for the mean of a univariate normal distribution. The code follows:\r\n\r\n    using Mamba\r\n    \r\n    ## Model Specification\r\n    \r\n    model = Model(\r\n    \r\n      x = Stochastic(1,\r\n        mu -> Normal(mu, 2.0),\r\n        false\r\n      ),\r\n    \r\n      mu = Stochastic(\r\n        () -> Normal(0.0, 1000.0),\r\n        true\r\n      )\r\n    \r\n    )\r\n    \r\n    ## Data\r\n    data = Dict{Symbol, Any}(\r\n      :x => randn(30)*2+13\r\n    )\r\n    \r\n    ## Initial Values\r\n    inits = [\r\n      Dict{Symbol, Any}(\r\n        :x => data[:x],\r\n        :mu => randn()*1\r\n      )\r\n    ]\r\n    \r\n    ## Sampling Scheme Assignment\r\n    scheme1 = NUTS([:mu])\r\n    setsamplers!(model, [scheme1])\r\n    \r\n    sim1 = mcmc(model, data, inits, 10000, burnin=250, thin=2, chains=1);\r\n    describe(sim1)\r\n\r\nThis seems to work absolutely fine (though there may be better ways perhaps of coding this?).\r\n\r\n\r\n**What I am trying to do and doesn't work.**\r\n\r\nIn this example, I am trying to do bayesian inference for the mean of a bivariate normal distribution. The code follows:\r\n\r\n\r\n    using Mamba\r\n    \r\n    ## Model Specification\r\n    \r\n    model = Model(\r\n    \r\n      x = Stochastic(1,\r\n        mu -> MvNormal(mu, eye(2)),\r\n        false\r\n      ),\r\n    \r\n      mu = Stochastic(1,\r\n        () -> MvNormal(zeros(2), 1000.0),\r\n        true\r\n      )\r\n    \r\n    )\r\n    \r\n    ## Data\r\n    data = Dict{Symbol, Any}(\r\n      :x => randn(2,30)+13\r\n    )\r\n    \r\n    ## Initial Values\r\n    inits = [\r\n      Dict{Symbol, Any}(\r\n        :x => data[:x],\r\n        :mu => randn(2)*1\r\n      )\r\n    ]\r\n    \r\n    ## Sampling Scheme Assignment\r\n    scheme1 = NUTS([:mu])\r\n    setsamplers!(model, [scheme1])\r\n    \r\n    sim1 = mcmc(model, data, inits, 10000, burnin=250, thin=2, chains=1);\r\n    describe(sim1)\r\n\r\n\r\nAs you may notice, the changes that I suppose are necessary are minimal. However, I am doing somewhere something wrong and when I attempt to run this I get an error (a conversion between types error) which does not help me further.\r\n\r\nAny help appreciated. If this works out, I will consider contribute this simple example to the Mamba documentation for other new users. Thanks.\r\n\r\n\r\n**The error message**\r\n\r\n    ERROR: MethodError: Cannot `convert` an object of type Array{Float64,2} to an object of type Array{Float64,1}\r\n    This may have arisen from a call to the constructor Array{Float64,1}(...),\r\n    since type constructors fall back to convert methods.\r\n     in setinits!(::Mamba.ArrayStochastic{1}, ::Mamba.Model, ::Array{Float64,2}) at /lhome/lgiannins/.julia/v0.5/Mamba/src/model/dependent.jl:164\r\n     in setinits!(::Mamba.Model, ::Dict{Symbol,Any}) at /lhome/lgiannins/.julia/v0.5/Mamba/src/model/initialization.jl:11\r\n     in setinits!(::Mamba.Model, ::Array{Dict{Symbol,Any},1}) at /lhome/lgiannins/.julia/v0.5/Mamba/src/model/initialization.jl:24\r\n     in #mcmc#29(::Int64, ::Int64, ::Int64, ::Bool, ::Function, ::Mamba.Model, ::Dict{Symbol,Any}, ::Array{Dict{Symbol,Any},1}, ::Int64) at /lhome/lgiannins/.julia/v0.5/Mamba/src/model/mcmc.jl:29\r\n     in (::Mamba.#kw##mcmc)(::Array{Any,1}, ::Mamba.#mcmc, ::Mamba.Model, ::Dict{Symbol,Any}, ::Array{Dict{Symbol,Any},1}, ::Int64) at ./<missing>:0\r\n\r\n\r\nPs. The question has been previously posted on StackOverflow at: http://bit.ly/2d6CcY1"}}
{"actor":{"display_login":"ngiann"}}