-
Notifications
You must be signed in to change notification settings - Fork 31
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
stan_sample generates R files in the tmpdir? #113
Comments
Hi Maxime ( @maximerischard ), That is a pretty old version of StanSample.jl. Are you sure this is StanSample v3.0.11? This looks more like v5 or v6? By default the number of chains is indeed 4. Dependent on which version of StanSample you are running I can show you how to change that. Which version of cmdstan are you using? You can see that in the first few lines of any of the .csv files in your Stan's executable (cmdstan) expects input data in the RDump format (or JSON format in StanSample.jl v6.3.0) hence I need to rework the Let me know if these instructions help. Best, Rob |
Hi Rob, Thank you for your quick answer. So I was indeed using an older version of StanSample so I updated all my Julia packages and am now using StanSample v6.3.0. I switched from the example above to the one on the Stan.jl page : https://stanjulia.github.io/Stan.jl/latest/WALKTHROUGH2/ The files created by stan_sample() are now JSON files. However, the model fails to run and the .csv files are not created. It gives me this error message :
My Julia startup file points to this version of cmdstan : ENV["JULIA_CMDSTAN_HOME"]="C:\Users\maxim\cmdstan-2.27.0" Thank you very much for your help again :) Maxime |
Hi Maxime,
Yes, this means you are using a cmdstan binary older than cmdstan-2.28.0. Do you remember how and when did you install that?
The output definitely shows it has been able to compile the Stan Language program. Do you mind sending me the output of ‘m6_1s` in the REPL and the output of `m6_1s.cmds`?
m6_1s.cmds should return a vector of 4 elements, the first one being:
```
`/Users/rob/.julia/dev/Stan/Examples/Walkthrough/tmp/m6.1s sample num_chains=1 num_samples=1000 num_warmup=1000 save_warmup=0 thin=1 adapt engaged=1 gamma=0.05 delta=0.85 kappa=0.75 t0=10 init_buffer=75 term_buffer=75 window=25 algorithm=hmc engine=nuts max_depth=10 metric=diag_e stepsize=1.0 stepsize_jitter=0.0 random seed=-1 init=2 id=1 data file=/Users/rob/.julia/dev/Stan/Examples/Walkthrough/tmp/m6.1s_data_1.json output file=/Users/rob/.julia/dev/Stan/Examples/Walkthrough/tmp/m6.1s_chain_1.csv refresh=100`
...
```
Older versions seem to stumble over the `num_chains=1` after the `sample` method keyword.
If it is too hard for you to install cmdstan-2.29.0, I can try to create a version that drops the `num_chains=1` on Windows.
Best,
Rob
Rob J Goedman
***@***.***
… On Feb 22, 2022, at 08:47, quantitative-ecologist ***@***.***> wrote:
Hi Rob,
Thank you for your quick answer. So I was indeed using an older version of StanSample so I updated all my Julia packages and am now using StanSample v6.3.0. I switched from the example above to the one on the Stan.jl page : https://stanjulia.github.io/Stan.jl/latest/WALKTHROUGH2/ <https://stanjulia.github.io/Stan.jl/latest/WALKTHROUGH2/>
The files created by stan_sample() are now JSON files. However, the model fails to run and the .csv files are not created. It gives me this error message :
# Run the model
rc6_1s = stan_sample(m6_1s; data, seed=-1, delta=0.85);
num_chains=1 is either mistyped or misplaced.
Failed to parse command arguments, cannot run model.
num_chains=1 is either mistyped or misplaced.
Failed to parse command arguments, cannot run model.num_chains=1 is either mistyped or misplaced.num_chains=1 is either mistyped or
misplaced.
F
ailed to parse command arguments, cannot run model.F
ailed to parse command arguments, cannot run model.
ERROR: LoadError: failed processes:
Process(`'C:\Users\maxim\OneDrive\Bureau\tests_julia\test\m6.1s.exe' sample num_chains=1 num_samples=1000 num_warmup=1000 save_warmup=0 thin=1 adapt engaged=1 gamma=0.05 delta=0.85 kappa=0.75 t0=10 init_buffer=75 term_buffer=75 window=25 algorithm=hmc engine=nuts max_depth=10 metric=diag_e stepsize=1.0 stepsize_jitter=0.0 random seed=-1 init=2 id=1 data 'file=C:\Users\maxim\OneDrive\Bureau\tests_julia\test\m6.1s_data_1.json' output 'file=C:\Users\maxim\OneDrive\Bureau\tests_julia\test\m6.1s_chain_1.csv' refresh=100`, ProcessExited(1)) [1]
Process(`'C:\Users\maxim\OneDrive\Bureau\tests_julia\test\m6.1s.exe' sample num_chains=1 num_samples=1000 num_warmup=1000 save_warmup=0 thin=1 adapt engaged=1 gamma=0.05 delta=0.85 kappa=0.75 t0=10 init_buffer=75 term_buffer=75 window=25 algorithm=hmc engine=nuts max_depth=10 metric=diag_e stepsize=1.0 stepsize_jitter=0.0 random seed=-1 init=2 id=2 data 'file=C:\Users\maxim\OneDrive\Bureau\tests_julia\test\m6.1s_data_2.json' output 'file=C:\Users\maxim\OneDrive\Bureau\tests_julia\test\m6.1s_chain_2.csv' refresh=100`, ProcessExited(1)) [1]
Process(`'C:\Users\maxim\OneDrive\Bureau\tests_julia\test\m6.1s.exe' sample num_chains=1 num_samples=1000 num_warmup=1000 save_warmup=0 thin=1 adapt engaged=1 gamma=0.05 delta=0.85 kappa=0.75 t0=10 init_buffer=75 term_buffer=75 window=25 algorithm=hmc engine=nuts max_depth=10 metric=diag_e stepsize=1.0 stepsize_jitter=0.0 random seed=-1 init=2 id=3 data 'file=C:\Users\maxim\OneDrive\Bureau\tests_julia\test\m6.1s_data_3.json' output 'file=C:\Users\maxim\OneDrive\Bureau\tests_julia\test\m6.1s_chain_3.csv' refresh=100`, ProcessExited(1)) [1]
Process(`'C:\Users\maxim\OneDrive\Bureau\tests_julia\test\m6.1s.exe' sample num_chains=1 num_samples=1000 num_warmup=1000 save_warmup=0 thin=1 adapt engaged=1 gamma=0.05 delta=0.85 kappa=0.75 t0=10 init_buffer=75 term_buffer=75 window=25 algorithm=hmc engine=nuts max_depth=10 metric=diag_e stepsize=1.0 stepsize_jitter=0.0 random seed=-1 init=2 id=4 data 'file=C:\Users\maxim\OneDrive\Bureau\tests_julia\test\m6.1s_data_4.json' output 'file=C:\Users\maxim\OneDrive\Bureau\tests_julia\test\m6.1s_chain_4.csv' refresh=100`, ProcessExited(1)) [1]
Stacktrace:
[1] pipeline_error(procs::Base.ProcessChain)
@ Base .\process.jl:538
[2] run(::Base.CmdRedirect; wait::Bool)
@ Base .\process.jl:440
[3] run
@ .\process.jl:438 [inlined]
[4] stan_run(m::SampleModel; kwargs::Base.Iterators.Pairs{Symbol, Any, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:data, :seed, :delta), Tuple{NamedTuple{(:H, :LL, :LR, :N), Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}, Int64}}, Int64, Float64}}})
@ StanSample C:\Users\maxim\.julia\packages\StanSample\4ayOP\src\stanrun\stan_run.jl:129
[5] top-level scope
@ c:\Users\maxim\OneDrive\Bureau\tests_julia\code\test_model.jl:62
in expression starting at c:\Users\maxim\OneDrive\Bureau\tests_julia\code\test_model.jl:62
My Julia startup file points to this version of cmdstan : ENV["JULIA_CMDSTAN_HOME"]="C:\Users\maxim\cmdstan-2.27.0"
Thank you very much for your help again :)
Maxime
—
Reply to this email directly, view it on GitHub <#113 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAAMX2A4LA2EJBKWKOVZKOTU4OVYBANCNFSM5O7UVQMA>.
You are receiving this because you commented.
|
Hi Maxine, A new version of StanSample.jl (v6.3.1) just got merged which I believe will, by default, be compatible with older versions of the cmdstan as long as the keyword argument So in the walkthrough examples:
will return a single DataFrame with all 4000 draws. Don't think Best, Rob |
Hi Rob, I updated to the newest version and the model runs like a charm. Thank you for your help. I look forward to using Stan.jl for my PhD project. I might get back to you soon when I start running complex multivariate hierarchical models :) Best, Maxime |
Your welcome Maxime (@quantitative-ecologist ), Glad it all works again, I should have come up with this approach much earlier. There are a few minor updates in the Stan Language that have been introduces in v2.28 and I think will be rejected in v2.32 (should be released in about a year). They are minor, e.g.: Just a heads up. Best, |
Good day,
First, I would like to thank you very much for the development of Stan for Julia. I am trying to understand the workflow of Stan.jl but something bugs me.
I am running this model from StatisticalRethinking.jl :
The models runs fine. However, what is wierd is that stan_sample generates four .R files as you can see below:
Why would this happen? I see that the four .R files re-generate the data that I already specified in my .jl script. Is this intended behavior from the package? I couldn't find any documentation pointing to this.
I am running the script on Julia REPL in VS Code under a Windows 10 computer OS with Julia version 1.6.1. The versions for StatisticalRethinking are 3.4.3 and 3.0.11 for StanSample.
Thank you very much for your help and I hope this is the proper way to report any issues/questions with the package.
Maxime
The text was updated successfully, but these errors were encountered: