Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example in documentation throws exception and an additional question #6

Closed
ghost opened this issue Oct 18, 2014 · 4 comments
Closed

Comments

@ghost
Copy link

ghost commented Oct 18, 2014

I learned a bit of Julia yesterday and I wanted to try Mamba, so please forgive me if there is a very elementary error on my part.

I'm running Julia 0.3.1 and Mamba from the master branch (although I don't think there is other way to install it since it is not recognized by Pkg.add("Mamba")). The model I was trying to run is Rats: A Normal Hierarchical Model. However, I get this error in the last part of the code:

julia> ## MCMC Simulations
   sim = mcmc(model, rats, inits, 10000, burnin=2500, thin=2, chains=2)
MCMC Simulation of 10000 Iterations x 2 Chains...

exception on 1: ERROR: `convert` has no method matching convert(::Type{FloatingPoint}, ::Int64)
in convert at base.jl:13
in next! at /home/ubuntu/.julia/v0.3/Mamba/src/progress.jl:21
in mcmc_worker! at /home/ubuntu/.julia/v0.3/Mamba/src/model/mcmc.jl:76
in anonymous at multi.jl:660
in run_work_thunk at multi.jl:621
in remotecall_fetch at multi.jl:694
in remotecall_fetch at multi.jl:709
in anonymous at task.jl:1365
ERROR: type MethodError has no field model
in mcmc_master! at /home/ubuntu/.julia/v0.3/Mamba/src/model/mcmc.jl:50
in mcmc at /home/ubuntu/.julia/v0.3/Mamba/src/model/mcmc.jl:37

I tested this in a fresh Ubuntu 14.04 installation. The same happens in this example.

The additional question is this: When you write something like this:

model = Model(
    y = Stochastic(1,
      quote
        mu = model[:mu]
        s2 = model[:s2]
        IsoNormal(mu, sqrt(s2))
      end,
      false
),

Does model[:mu] refer to a node contained in the dictionary defined as model = Model(...? I'm asking this because that part seems to have a recursive-like quality.

Thanks!

@ghost ghost changed the title Example in documentation throws exception and a little question Example in documentation throws exception and an additional question Oct 18, 2014
@brian-j-smith
Copy link
Owner

@rsmith31415,

Thanks for bringing that error to my attention. Apparently, it is being caused by one of the other packages that Mamba depends on. I just uploaded an updated version of Mamba (0.3.6) that should fix the problem. Let me know if the latest version does not work for you.

You're right, the two occurrences of model in your code example do make things look recursive. They're different though. model = Model(...) is a Model object with a user-specified name. It can be called anything (e.g. mymodel = Model(...)) and is external to the model fitting algorithms implemented in the mcmc methods. The model terms inside the calls to Stochastic (and Logical) refer to a copy of the Model object that is used internally by the algorithms. The internal copy is always called model.

In practice, you really only need to name the external Model object. The internal one does not need to be referenced directly if you use the @modelexpr macro, which I recommend doing. For instance, your example can be re-written without the internal model references as

model = Model(
    y = Stochastic(1,
      @modelexpr(mu, s2,
        IsoNormal(mu, sqrt(s2))
      ),
      false
    ),

P.S. Pkg.clone("git://github.com/brian-j-smith/Mamba.jl.git") installs the package.

@goedman
Copy link

goedman commented Oct 19, 2014

Hi Brian,

Yes, 0.3.6 indeed fixes the issue, I also had started to look which package ‘masked’ the convert() if that is the proper terminology.

Regards,
Rob J. Goedman
[email protected]

On Oct 19, 2014, at 1:45 PM, Brian J Smith [email protected] wrote:

@rsmith31415 https://github.com/rsmith31415,

Thanks for bringing that error to my attention. Apparently, it is being caused by one of the other packages that Mamba depends on. I just uploaded an updated version of Mamba (0.3.6) that should fix the problem. Let me know if the latest version does not work for you.

You're right, the two occurrences of model in your code example do make things look recursive. They're different though. model = Model(...) is a Model object with a user-specified name. It can be called anything (e.g. mymodel = Model(...)) and is external to the model fitting algorithms implemented in the mcmc methods. The model terms inside the calls to Stochastic (and Logical) refer to a copy of the Model object that is used internally by the algorithms. The internal copy is always called model.

In practice, you really only need to name the external Model object. The internal one does not need to be referenced directly if you use the @modelexpr macro, which I recommend doing. For instance, your example can be re-written without the internal model references as

model = Model(
y = Stochastic(1,
@modelexpr(mu, s2,
IsoNormal(mu, sqrt(s2))
),
false
),

Reply to this email directly or view it on GitHub #6 (comment).

@brian-j-smith
Copy link
Owner

Thanks for the confirmation Rob. I ended up downgrading packages one-at-a-time until I found the culprit. Then, I saw that there is a thread over at the Color package about it at JuliaAttic/Color.jl#68. There seems to be some questions about the root cause of the masking of convert, but regardless it affects conversion of integers to floats, which breaks core julia functionality and is a pretty serious problem IMO.

@ghost
Copy link
Author

ghost commented Oct 20, 2014

Thank you Brian for your explanation on Model and model. Now it makes perfect sense.

As Rob said, the error has been solved.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants