JagsJulia / Jags.jl

Julia package for using Jags as an external program
Other
17 stars 5 forks source link

problems #1

Closed cwliu007 closed 10 years ago

cwliu007 commented 10 years ago

Hi goedman,

I found two problems:

  1. If the data[:x] = [1, 2, 3, 4, 5] (one-dimensional data) is replaced with data[:x] = eye(5) (any two-dimensional data), the data cannot be correctly written in line-data.R.
  2. If the data[:x] = [1, 2, 3, 4, NaN] contains NaN, the datum written in line-data.R is still NaN instead of NA. It seems JAGS only handle NA, right?
  3. Could I specify how many chains to run? How about warm up, update, and DIC? It would be good for me in this way to use Jagsmodel(chains = 2, warmup = 2000, update = 5000, dic = true). Hope you will consider it :)
  4. When I run the line example, it reads "could not spawn jags line.jags: no such file or directory (ENOENT)". Is that I didn't correctly set up my JAGS?

Finally, many thanks for your efforts on developing this useful package :+1:

goedman commented 10 years ago

Hi genwei,

Thank you for the feedback. The package has not been released yet, so many aspects will be missing or are being implemented as we speak. Your questions will certainly help me set my priorities!

First on my list would be to make the line example work on your system.

Item 4) I'm assuming jags is installed and works? I.e. in the Julia REPL type ;jags:

shell> jags Welcome to JAGS 3.4.0 on Fri Aug 1 09:29:00 2014 JAGS is free software and comes with ABSOLUTELY NO WARRANTY Loading module: basemod: ok Loading module: bugs: ok . ^D julia>

Use ^D to close Jags.

3) Yes, Jagsmodel has a keyword argument chains with a default value of 4:

julia> jagsmodel name = "line" chains = 4 adapt = 1000 update = 10000 thin = 10 monitors = [:tau=>true,:sigma=>true,:alpha=>true,:beta=>true] jags_file = "line.jags" model_file = "line.bugs" init_file = "line-inits.R" data_file = "line-data.R"

Items 1) and 2) have not yet been implemented. I will look at those the next couple of days.

As you probably noted, I'm attempting to develop Stan.jl and Jags.jl in parallel and compare the outputs with Julia's Mamba package. So Stan.jl and Jags.jl leapfrog each other when features are added.

Regards, Rob

cwliu007 commented 10 years ago

Hi goedman,

  1. My system is Windows 7 64bit, I had installed JAGS3.4.0.exe and addedC:\Program Files\JAGS\JAGS-3.4.0\x64\bin to Path of System Variables. However, Julia REPL still reports could not spawn jags: no such file or directory (ENOENT). But I found run("XXX.bat") where the .bat contains jags line.jags works. Not sure what I missed?
  2. DIC is possible?

I noted that you are also developing Stan.jl. It looks nice. I have some experiences with rstan in R, it is easy to use. But it seems to setup the cmdStan is quite a complex job for me. Anyway, I will try out the Stan.jl if I can handle the cmdStan setup.

Thanks :)

goedman commented 10 years ago

Hi genwei,

1) Would you mind sending me your XXX.bat?

I should be able to generate that file and then in Julia's REPL do : run(run("XXX.bat"))

Here I'm assuming on Windows Julia's run(...) works ok.

Does, in Julia's REPL, ';' work to put you in shell mode?

2) Not clear what exactly you are asking, but Jagsmodel returns a object of type Jagsmodel. It is certainly possible to update all the fields in that object, e.g.

using Jags jagsmodel = Jags(name="line) jagsmodel |> display

jagsmodel.chains = 6

Or maybe you're asking if it wouldn't be better to make the jagsmodel a dictionary?

Rob J. Goedman goedman@icloud.com

On Aug 1, 2014, at 11:00 AM, genwei007 notifications@github.com wrote:

Hi goedman,

My system is Windows 7 64bit, I had installed JAGS3.4.0.exe and add C:\Program Files\JAGS\JAGS-3.4.0\x64\bin to Path of System Variables. However, Julia REPL still reports could not spawn jags line.jags: no such file or directory (ENOENT). But I found run("XXX.bat") which contains jags line.jags works. Not sure what I missed?

DIC is possible?

I noted that you are also developing Stan.jl. It looks nice. I have some experience with rstan in R, it is easy to use. But it seems to setup the cmdStan is quite complex job for me. Anyway, I will try out the Stan.jl if I can handle the cmdStan setup.

Thanks :)

— Reply to this email directly or view it on GitHub.

cwliu007 commented 10 years ago
  1. It is easy to have XXX.bat. Create a new file called XXX.bat, just write down a line jags line.jags (i.e., JAGS' command to run model) in it and then save.

To run JAGS, switch to the line example working folder and then Input

run(`XXX.bat`) 

in Julia's REPL. JAGS will be invoked to run line example.

Note: The JAGS's path should be added first to system path. In my case, it is C:\Program Files\JAGS\JAGS-3.4.0\x64\bin on x64 system.

Yes, the ; can change Julia's REPL to shell mode.

2) Sorry for the unclear. I was talking about Deviance information criterion (DIC). I always fail to make JAGS's dic module work to get the DIC value. It seems the Jags.jl is not capable of this for now, right?

3) I have a quick test for your updated Jags.jl. The written R data has unnecessary () like .Dim=c((2,2)) instead of .Dim=c(2,2).

4) For initial values, to give NaN should be possible.

5) BTW, is it possible to optionally run multiple chains in parallel?

Best regards,

genwei

cwliu007 commented 10 years ago

Today, I raised a question at https://groups.google.com/forum/?fromgroups=#!topic/julia-users/VEihX-31EkA and got a method to run JAGS model without using XXX.bat on Windows.

Take line example for example: 1) Firtsly, add exit command in line.jags, 2) In Julia REPL, input

run(`cmd /c jags line.jags`)

or succinctly

run(`cmd /c jags line.jags exit`)

without adding exit in line.jags

cwliu007 commented 10 years ago

Jagsmodel(..., thin = 10) seems not printing out monitor variable, thin(10) in .jags file.

goedman commented 10 years ago

Thank you! For now I'll use that approach.

I've also been looking into the DIC question, but have not figured out yet how to do this from a jags command file. Yesterday did get it to work in R. At some point I might have to dig into the C/C++ interface options in Julia (C or C++ FFI) as Jameson suggested.

Also, made a few changes related to you items 1 and 2. And will also look into the thinning issue. I might reorg the issues a bit to have separate issues which at some point, when resolved, can be closed.

Regards, Rob

Sent from Rob Goedman's iPad Mini

On Aug 2, 2014, at 23:21, genwei007 notifications@github.com wrote:

Today, I raised a question at https://groups.google.com/forum/?fromgroups=#!topic/julia-users/VEihX-31EkA and got a method to run JAGS model without using XXX.bat on Windows.

Take line example for example: 1) Firtsly, add exit command in line.jags, 2) In Julia REPL, input

run(`cmd /c jags line.jags`)

— Reply to this email directly or view it on GitHub.

cwliu007 commented 10 years ago

Some issues were also found: 3) I have a quick test for your updated Jags.jl. The written R data has unnecessary () like .Dim=c((2,2)) instead of .Dim=c(2,2).

4) For initial values, to give NaN should be possible.

5) BTW, is it possible to optionally run multiple chains in parallel?

Best regards

goedman commented 10 years ago

I believe all of these issues have been moved to separate issues. Will close this overall issue for now.