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

CompatHelper: bump compat for "Turing" to "0.16" #216

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Jun 3, 2021

This pull request changes the compat entry for the Turing package from 0.12, 0.13, 0.14, 0.15 to 0.12, 0.13, 0.14, 0.15, 0.16.

This keeps the compat entries for earlier versions.

Note: I have not tested your package with this new compat entry. It is your responsibility to make sure that your package tests pass before you merge this pull request.

@ChrisRackauckas ChrisRackauckas force-pushed the compathelper/new_version/2021-06-03-02-42-43-659-1397580942 branch from c0e3eb7 to 082d58a Compare June 3, 2021 02:42
Copy link
Member

@Vaibhavdixit02 Vaibhavdixit02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Rob @goedman, I am updating the wrapper here to the updated syntax from Stan but haven't been able to make it work yet, would you be able to take a look? Any pointers will be appreciated. If you try to run the test please make sure to use JuliaSymbolics/Symbolics.jl#255 branch fro Symbolic since that has some updates needed here

@goedman
Copy link

goedman commented Jul 5, 2021

I'll have a look a bit later today. Thanks for the heads up.

@goedman
Copy link

goedman commented Jul 6, 2021

Took a quick look yesterday evening. The results vaguely remind me of the problem we had a while ago as the parameters never move away from the initial values given the used priors and hence the tests will fail:

11×10 DataFrame
 Row │ parameters     mean         mcse          std          5%           50%          95%          ess      n_eff/s  r_hat      
     │ Symbol         Float64      Float64       Float64      Float64      Float64      Float64      Float64  Float64  Float64    
─────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1 │ lp__            192.095       0.10218     1.17905       189.682      192.403      193.321     133.148  309.647    0.996884
   2 │ accept_stat__     0.882685    0.00780499  0.111659        0.663471     0.903533     1.0       204.663  475.961    1.00595
   3 │ stepsize__        0.391537  NaN           4.44831e-16     0.391537     0.391537     0.391537  NaN      NaN      NaN
   4 │ treedepth__       2.82        0.0432666   0.704216        2.0          3.0          4.0       264.914  616.08     0.996661
   5 │ n_leapfrog__      8.32        0.235974    4.02554         3.0          7.0         15.0       291.019  676.787    0.997989
   6 │ divergent__       0.0       NaN           0.0             0.0          0.0          0.0       NaN      NaN      NaN
   7 │ energy__       -190.619       0.170712    1.78916      -192.69      -191.111     -187.075     109.843  255.45     0.996662
   8 │ sigma1[1]         0.062       0.00058     0.0076          0.051        0.061        0.074     171.0    397.0      1.0
   9 │ sigma1[2]         0.063       0.00068     0.0084          0.051        0.062        0.079     150.0    349.0      1.0
  10 │ theta1            1.5         0.0         0.0             1.5          1.5          1.5       254.36   591.54     1.0
  11 │ theta[1]          1.5         3.2e-5      0.00051         1.5          1.5          1.5       254.0    592.0      1.0

Need to dig deeper into this and understand better what has changed.

@Vaibhavdixit02
Copy link
Member

Did it not throw any error for you?

@goedman
Copy link

goedman commented Jul 6, 2021

No it doesn't until line 38 in stan.jl. The same as on CI actions for test(Stan).

@goedman
Copy link

goedman commented Jul 6, 2021

I haven't figured out what you mean with your above hint about Symbolics#255, so I'm clearly missing pieces.

@goedman
Copy link

goedman commented Jul 6, 2021

All priors in paremeter_estimates_model.stan are of the form theta[...] ~ normal(.., 0.01) and truncated.

@Vaibhavdixit02
Copy link
Member

Vaibhavdixit02 commented Jul 6, 2021

I haven't figured out what you mean with your above hint about Symbolics#255, so I'm clearly missing pieces.

Yeah, are you using Cmdstan version older than 2.24? The syntax for ODEs has changed after that that's why you need the Symbolics PR. Ref: https://github.com/stan-dev/example-models/tree/master/knitr/convert-odes

@goedman
Copy link

goedman commented Jul 6, 2021

I'm using cmdstan 2.27.0.

@Vaibhavdixit02
Copy link
Member

This is what the *_build.log looks like for me without the Symbolics branch (and same error code and lines as CI)


Semantic error in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 48, column 14 to column 75:
   -------------------------------------------------
    46:        sigma1 ~ inv_gamma(3.0, 3.0);
    47:        theta_1 ~normal(1.5, 0.1) T[1.0,1.8];
    48:        u_hat = ode_rk45_tol(sho, u0, t0, ts, 0.001, 1.0e-6, 100000, theta_1);
                       ^
    49:        for (t in 1:T){
    50:          internal_var___u[t,:] ~ normal(u_hat[t,1:2],sigma1);
   -------------------------------------------------

Ill-typed arguments supplied to function 'ode_rk45_tol'. Expected arguments:
(real, vector) => vector, vector, real, real[], real, real, int
Instead supplied arguments of incompatible type:
(real, real[], real[], real[], int[]) => real[], vector, real, real[], real, real, int, real

make: *** [/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.hpp] Error 1

whereas with #255 there is nothing in the build logs but this is the issue I think is the blocker, in the *_run.log we have


Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)
Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in '/Users/vaibhavdixit/DiffEqBayes.jl/tmp/parameter_estimation_model.stan', line 47, column 6 to column 43)

Initialization between (-2, 2) failed after 100 attempts. 
 Try specifying initial values, reducing ranges of constrained values, or reparameterizing the model.
Initialization failed.

@goedman
Copy link

goedman commented Jul 6, 2021 via email

@goedman
Copy link

goedman commented Jul 6, 2021

Now I'm at the point where the compilations of the Stan Language program fails, exactly as in your post.

I tried simply add Symbolics#255 but that fails:

DiffEqBayesCmdStan) pkg> add Symbolics#255
ERROR: GitError(Code:EAMBIGUOUS, Class:Object, ambiguous lookup - OID prefix is too short)
Stacktrace:
  [1] macro expansion
    @ /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/LibGit2/src/error.jl:110 [inlined]
  [2] LibGit2.GitObject(repo::LibGit2.GitRepo, spec::String)
    @ LibGit2 /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/LibGit2/src/repository.jl:142
  [3] get_object_or_branch(repo::LibGit2.GitRepo, rev::String)
    @ Pkg.Types /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Pkg/src/Type

<many more>

Symbolics does include #285.

(DiffEqBayes) pkg> st
     Project DiffEqBayes v2.25.0
      Status `~/.julia/dev/DiffEqBayes/Project.toml`
  [f5f396d3] ApproxBayes v0.3.2
  [593b3428] CmdStan v6.3.0
  [2b5f629d] DiffEqBase v6.68.1
  [163ba53b] DiffResults v1.0.3
  [b4f34e82] Distances v0.9.2
  [31c24e10] Distributions v0.23.11
  [ffbed154] DocStringExtensions v0.8.5
  [bbc10e6e] DynamicHMC v3.1.0
  [f6369f11] ForwardDiff v0.10.18
  [2ee39098] LabelledArrays v1.6.2
  [6fdf6af0] LogDensityProblems v0.10.6
  [1914dd2f] MacroTools v0.5.6
  [e1d29d7a] Missings v1.0.0
  [961ee093] ModelingToolkit v5.21.0
  [429524aa] Optim v1.3.0
  [1dea7af3] OrdinaryDiffEq v5.59.3
  [90014a1f] PDMats v0.10.1
  [65888b18] ParameterizedFunctions v5.10.0
  [d96e819e] Parameters v0.12.2
  [731186ca] RecursiveArrayTools v2.14.5
  [189a3867] Reexport v1.1.0
  [ae029012] Requires v1.1.3
  [09ab397b] StructArrays v0.5.1
  [84d833dd] TransformVariables v0.4.0
  [fce5fe82] Turing v0.16.5
  [8ba89e20] Distributed
  [37e2e46d] LinearAlgebra
  [9a3f8284] Random

(DiffEqBayes) pkg> st Symbolics
     Project DiffEqBayes v2.25.0
  No Matches in `~/.julia/dev/DiffEqBayes/Project.toml`

@Vaibhavdixit02
Copy link
Member

Yeah we merged the PR in Symbolics so you can use the master branch now, it should work with either of ]add https://github.com/JuliaSymbolics/Symbolics.jl.git or ]add git@github.com:JuliaSymbolics/Symbolics.jl.git, sorry for the additional steps 😅

@goedman
Copy link

goedman commented Jul 7, 2021

Thanks. Tried with the master version of Symbolics but still run into the Stan compilation failure. Would you mind sending me your .stan file?

I’m up in the mountains today and tomorrow, so definitely Friday I will be able to focus more on this issue.

@Vaibhavdixit02
Copy link
Member

Sure, I'll email it

@goedman
Copy link

goedman commented Jul 8, 2021

Somehow parts seem to update ok, but the sho function is different. Below 'my' version of the .stan file you sent me:

functions {
        int bin_search(real x, int min_val, int max_val){
    int range = (max_val - min_val + 1) / 2;
    int mid_pt = min_val + range;
    int out;
    while (range > 0) {
        if (x == mid_pt) {
            out = mid_pt;
            range = 0;
        } else {
            range = (range + 1) / 2; 
            mid_pt = x > mid_pt ? mid_pt + range: mid_pt - range; 
        }
    }
    return out;
}

      real[] sho(real t,real[] internal_var___u,real[] internal_var___p,real[] x_r,int[] x_i) {
  real internal_var___du[2];
  internal_var___du[1] = internal_var___p[1] * internal_var___u[1] - internal_var___u[1] * internal_var___u[2];
  internal_var___du[2] = internal_var___u[2] * -3 + internal_var___u[1] * internal_var___u[2];
  return internal_var___du;
}

    }
    data {
      vector[2] u0;
      int<lower=1> T;
      real internal_var___u[T,2];
      real t0;
      real ts[T];
    }
    transformed data {
      real x_r[0];
      int x_i[0];
    }
    parameters {
      row_vector<lower=0>[2] sigma1;
      real<lower=1.0,upper=1.8> theta1;
    }
    transformed parameters{
      real theta_1;
    }
    model{
      vector[2] u_hat[T];
      sigma1 ~ inv_gamma(3.0, 3.0);
      theta_1 ~normal(1.5, 0.1) T[1.0,1.8];
      u_hat = ode_rk45_tol(sho, u0, t0, ts, 0.001, 1.0e-6, 100000, theta_1);
      for (t in 1:T){
        internal_var___u[t,:] ~ normal(u_hat[t,1:2],sigma1);
        }
    }

This is created in the build_function of Symbolics.jl.

@Vaibhavdixit02
Copy link
Member

Can you confirm if you are using either Symbolics#master or not? That looks like old syntax, which actually shouldn't work with a new version of CmdStan so it's a little confusing for me at the moment. ref: https://github.com/stan-dev/example-models/blob/master/knitr/convert-odes/convert_odes.Rmd

@goedman
Copy link

goedman commented Jul 9, 2021

Hi Vaibhav,

Thank you. That helps, now the sho function is similar to your script.

In both test setups (runtests.jl in DiffEqBayes as normal and a direct test script using the Stan Language program) I'm now seeing an initialization failure. I'll dig into that one.

What surprises me a bit is the unused parameter to sho, the internal_var___p_1 variable (which I would expect to represent a - theta_1? - in the calculation of `dx).

@goedman
Copy link

goedman commented Jul 9, 2021

Looked a bit more into the initialization issue and with below updated script:

using StanSample, DiffEqBayes, OrdinaryDiffEq, ParameterizedFunctions,
      RecursiveArrayTools, Distributions, StatsPlots, Test

ProjDir = @__DIR__

println("One parameter case")
f1 = @ode_def begin
  dx = a*x - x*y
  dy = -3y + x*y
end a
u0 = [1.0,1.0]
tspan = (0.0,10.0)
p = [1.5]
prob1 = ODEProblem(f1,u0,tspan,p)
sol = solve(prob1,Tsit5())
t = collect(range(1,stop=10,length=50))
randomized = VectorOfArray([(sol(t[i]) + .01randn(2)) for i in 1:length(t)])
data = convert(Array,randomized)

stan_pes = "
  functions {
    int bin_search(real x, int min_val, int max_val){
      int range = (max_val - min_val + 1) / 2;
      int mid_pt = min_val + range;
      int out;
      while (range > 0) {
          if (x == mid_pt) {
              out = mid_pt;
              range = 0;
          } else {
              range = (range + 1) / 2; 
              mid_pt = x > mid_pt ? mid_pt + range: mid_pt - range; 
          }
      }
      return out;
    }

    vector sho(real t,vector internal_var___u, real internal_var___p_1) {
      vector[2] internal_var___du;
      internal_var___du[1] = internal_var___p_1 * internal_var___u[1] - internal_var___u[1] * internal_var___u[2];
      internal_var___du[2] = internal_var___u[2] * -3 + internal_var___u[1] * internal_var___u[2];
      return internal_var___du;
    }

  }
  data {
    vector[2] u0;
    int<lower=1> T;
    real internal_var___u[T, 2];
    real t0;
    real ts[T];
  }
  transformed data {
    real x_r[0];
    int x_i[0];
  }
  parameters {
    row_vector<lower=0>[2] sigma1;
    real<lower=1.0,upper=1.8> theta_1;
  }
  model{
    vector[2] u_hat[T];
    sigma1 ~ inv_gamma(3.0, 3.0);
    theta_1 ~ normal(1.5, 0.1) T[1.0,1.8];
    u_hat = ode_rk45_tol(sho, u0, t0, ts, 0.001, 1.0e-6, 100000, theta_1);
    for (t in 1:T){
      internal_var___u[t,:] ~ normal(u_hat[t,1:2],sigma1);
      }
  }

";

pess = SampleModel("pess", stan_pes; tmpdir=joinpath(ProjDir, "tmp"))
data = (u0=u0, T=size(t, 1), internal_var___u=convert(Array,randomized)',
  t0=0.0, ts=t)
rc = stan_sample(pess; data)

if success(rc)
  pt = read_samples(pess; output_format=:particles)
  df = read_samples(pess; output_format=:dataframe)
  dfs = read_samples(pess; output_format=:dataframes)
  sdf = read_summary(pess)
  sdf |> display

  for i in 1:4
    if i == 1
      plot(dfs[i][:, "theta_1"])
    else
      plot!(dfs[i][:, "theta_1"])
    end
  end
  savefig(joinpath(ProjDir, "tmp", "pes.png"))

end

I get:

10×10 DataFrame
 Row │ parameters     mean         mcse         std       5%           50%          95%          es ⋯
     │ Symbol         Float64      Float64      Float64   Float64      Float64      Float64      Fl ⋯
─────┼───────────────────────────────────────────────────────────────────────────────────────────────
   1 │ lp__            192.416       0.029013   1.24291    189.974      192.741      193.74      18 ⋯
   2 │ accept_stat__     0.880192    0.0018153  0.119266     0.639208     0.908939     1.0       43
   3 │ stepsize__        0.576921    0.0153417  0.021729     0.561487     0.567712     0.614357
   4 │ treedepth__       2.3925      0.009016   0.564822     2.0          2.0          3.0       39
   5 │ n_leapfrog__      5.494       0.0324182  2.00922      3.0          7.0          7.0       38 ⋯
   6 │ divergent__       0.0       NaN          0.0          0.0          0.0          0.0        N
   7 │ energy__       -190.917       0.0436648  1.75885   -193.077     -191.237     -187.672     16
   8 │ sigma1[1]         0.062       0.00016    0.0084       0.05         0.062        0.077     27
   9 │ sigma1[2]         0.06        0.00016    0.0083       0.048        0.06         0.075     25 ⋯
  10 │ theta_1           1.5         0.0        0.0          1.5          1.5          1.5       38

and

pes

@goedman
Copy link

goedman commented Jul 9, 2021

What changes did I make?

  1. Updated sho() as I touched on above (using internal;_var__p == theta_1 draw)
  2. Transposed the input matrix.

Another edit: I dropped the transformed parameters block. I think this was the reason of the initialization errors. Theta_1 was not constrained.

Yet another edit: I think the transformed data block can also be dropped.

Is the bin_search function still used?

@Vaibhavdixit02
Copy link
Member

Vaibhavdixit02 commented Jul 10, 2021

I couldn't get it to work with CmdStan.jl but it's now working with StanSample.jl, do you think we can switch to that? It does have a WIP in the description but we don't really mind that haha 🙂

@goedman
Copy link

goedman commented Jul 10, 2021

Hi Vaibhav,

Not sure what you mean by StanModel.jl. Do you mean SampleModel as defined in StanSample.jl or StanModel as defined in the older CmdStan.jl?

Either one, StanSample.jl or CmdStan.jl should work but StanSample.jl has more ways of setting up the input and some newer approaches to read in the .csv files created by Stan's cmdstan executable. So in order to understand what was going wrong I switched to using StanSample.jl and test the .stan file created by DiffEqBayes' stan.jl/staninference.jl.

When you say it's now working you mean a new version of the Symbolics' build_function creates a correct version of function sho(), similar to how I manually updated sho (the ODE system function) in above script?

Do you think we still need the bin_search, the transformed_data and transformed_parameter sections? Or do you envisage cases where those will be used or generated by Symbolics.jl or stan_inference.jl?

@goedman
Copy link

goedman commented Jul 10, 2021

You are absolutely right that I have left StanSample.jl and several others like StanOptimize.jl, etc. too long marked as WIP.

Only recently I started to use the Tables.jl interface to handle chains (which in v4 of StanSample.jl etc. will become the default output_format) and looking at AlgebraOfGraphics.jl. Once v4 of these packages is released (late this year?) I will get more serious in deprecating the old CmdStan.jl.

So it is really up to you if you prefer to continue with CmdStan.jl for now or switch to StanSample.jl. The changes in DiffEqBayes' stan.jl and stan_inference.jl will be relatively simple. But I would love to see Symbolics.jl's build function to work!

@Vaibhavdixit02
Copy link
Member

Do you think we still need the bin_search, the transformed_data and transformed_parameter sections? Or do you envisage cases where those will be used or generated by Symbolics.jl or stan_inference.jl?

No I don't think so, I read the Stan docs to check what they could be used for by us by I don't think we need them. I think you agree?

switch to StanSample.jl.

Yeah I find the interface easier to use in this and our test works on it as well now so I'll just update with it but wanted to confirm with you first.

When you say it's now working you mean a new version of the Symbolics' build_function creates a correct version of function sho(), similar to how I manually updated sho (the ODE system function) in above script?

Yes! It finally does. Had to make some changes to Symbolics and created this PR for it JuliaSymbolics/Symbolics.jl#298 which looks like has been merged so it should work with master now.

@goedman
Copy link

goedman commented Jul 10, 2021

Great, I'll pick these changes up once they are on master and play a bit more with them.

I really get lost in trying to apply a fix on a pull request on a forked repo.

@Vaibhavdixit02
Copy link
Member

This PR has also removed the ABC support we had but there's already been discussion in #192 that it can not be supported going forward so I will take a look at adding a different library from a separate PR.

@Vaibhavdixit02 Vaibhavdixit02 merged commit ea7fa7c into master Jul 12, 2021
@Vaibhavdixit02 Vaibhavdixit02 deleted the compathelper/new_version/2021-06-03-02-42-43-659-1397580942 branch July 12, 2021 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants