soil-metamodel / stan

Stan models and associated R code
2 stars 5 forks source link

soil_incubation.stan #8

Open will246 opened 6 months ago

will246 commented 6 months ago

Hello there,

When I try to run soil_incubation.stan with the example data from the SoilR package (https://mc-stan.org/users/documentation/case-studies/soil-knit.html), I get the following error:

`Error in stanc(file = file, model_code = model_code, model_name = model_name, : 0

Semantic error in 'string', line 93, column 13 to line 94, column 57:

Ill-typed arguments supplied to function 'integrate_ode'. Available signatures: ((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,] Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[], real[], real[], int[].`

Do you know of any possible reasons for this? Thank you.

dlebauer commented 6 months ago

Hi @will246, thanks for reporting this! I was able to generate the same error, but unfortunately don't know the solution. I do suspect that it has to do with the fact that a) the code is almost a decade old, and the underlying software has likely changed! e.g. the eCO2 dataset from SoilR is different and you can load the original like this:

download.file('https://github.com/cran/SoilR/raw/1.1-23/data/eCO2.rda', 
              'eCO2.rda')
load('eCO2.rda')

In addition, stan has changed and the function integrate_ode has been deprecated as described in https://mc-stan.org/docs/functions-reference/functions-old-ode-solver.html.

Hopefully the author and Stan developer @bob-carpenter has some insight.

nsiccha commented 6 months ago

@dlebauer is likely correct. I had also recently had a look at the case study, and also found some conceptual errors. I'd recommend to rework it a bit more thoroughly and then re-upload it.

bob-carpenter commented 6 months ago

Hi, @dlebauer. There are a bunch of things that have changed in our interfaces, so probably best to rewrite. Hi, @nsiccha --- what did you want to fix conceptually? I'm happy to review.

ktoddbrown commented 6 months ago

Hi folks. I have some students who might be interested in revising this if you don't mind a longer time horizon.

@nsiccha I'm curious what you meant by conceptual errors here.

nsiccha commented 6 months ago

I hope everyone had nice holidays.

@bob-carpenter and @ktoddbrown: The following are things I would change.

I'd be happy to help with rewriting, improving and/or extending the case study, though I don't think I'll have time before February. What kind of time frame did you have in mind, @ktoddbrown?

will246 commented 6 months ago

Thank you for your input everyone @dlebauer @ktoddbrown @nsiccha. I was eventually able to get it to run. I used soil_incubation.stan from https://github.com/soil-metamodel/stan/tree/master/soil-incubation. It seems that the syntax in that file is different to that shown on the example page (https://mc-stan.org/users/documentation/case-studies/soil-knit.html). @nsiccha, I noticed the issues with mixing as well. I can look into this further too.

bob-carpenter commented 6 months ago
will246 commented 6 months ago

Thank you for your input everyone @dlebauer @ktoddbrown @nsiccha. I was eventually able to get it to run. I used soil_incubation.stan from https://github.com/soil-metamodel/stan/tree/master/soil-incubation. It seems that the syntax in that file is different to that shown on the example page (https://mc-stan.org/users/documentation/case-studies/soil-knit.html). @nsiccha, I noticed the issues with mixing as well. I can look into this further too.

Actually, I used soil_incubation.stan from here: https://github.com/stan-dev/example-models/blob/master/knitr/soil-carbon/soil_incubation.stan.