# Error with Bayesian workflow for disease transmission tutorial

**URL:** <https://discourse.mc-stan.org/t/error-with-bayesian-workflow-for-disease-transmission-tutorial/16253>\
**Category:** Modeling\
**Tags:** epidemiology, rstan, fitting-issues\
**Created:** [June 27, 2020, 11:51pm UTC](https://discourse.mc-stan.org/t/error-with-bayesian-workflow-for-disease-transmission-tutorial/16253 "2020-06-27T23:51:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ian.Frankenburg](https://avatars.discourse-cdn.com/v4/letter/i/b4bc9f/32.png) [@Ian.Frankenburg](https://discourse.mc-stan.org/u/Ian.Frankenburg)\
**Post date:** [June 27, 2020, 11:51pm UTC](https://discourse.mc-stan.org/t/error-with-bayesian-workflow-for-disease-transmission-tutorial/16253/1 "2020-06-27T23:51:01Z")

</div>

I’m trying to follow along with [Bayesian workflow for disease transmission modeling in Stan](https://mc-stan.org/users/documentation/case-studies/boarding_school_case_study.html#3_scaling_up_ode-based_models), but unfortunately I can’t get the example to run. I’ve used exactly the code provided in the tutorial with no alterations, but I get the error

```
[1] "Error in sampler$call_sampler(args_list[[i]]) : "
[2] " c++ exception (unknown reason)"                
error occurred during calling the sampler; sampling not done

```

I found [this](https://discourse.mc-stan.org/t/attempt-to-generate-prior-predictive-samples-from-sir-model/15468), which seemed to suggest the error could be within the negative binomial function. But the suggested fix doesn’t appear to work for me. Any thoughts?

---

<div class="post-metadata">

**Author:** ![ziqing-ang](https://avatars.discourse-cdn.com/v4/letter/z/e47c2d/32.png) [@ziqing-ang](https://discourse.mc-stan.org/u/ziqing-ang)\
**Post date:** [June 28, 2020, 12:19am UTC](https://discourse.mc-stan.org/t/error-with-bayesian-workflow-for-disease-transmission-tutorial/16253/2 "2020-06-28T00:19:48Z")

</div>

Hi Ian. I’m unfamiliar with rStan but just by your description alone I assume the problem arises when you’re trying to compile the Stan model. Have you come across this by any chance:

> **[Post a bounty on stan-dev/rstan!](https://www.bountysource.com/issues/83386474-error-in-sampler-call_sampler-args_list-i-c-exception-unknown-reason)**
>
> stan-dev/rstan

Also, just to confirm, did you save the model in “sir\_negbin.stan” as suggested in the source and then had the problem when you run the lines below?

```
model <- stan_model("sir_negbin.stan")
fit_sir_negbin <- sampling(model,
                data = data_sir,
                iter = niter,
                chains = 4)

```

---

<div class="post-metadata">

**Author:** ![maxbiostat](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/maxbiostat/32/1326_2.png) [@maxbiostat](https://discourse.mc-stan.org/u/maxbiostat)\
**Post date:** [June 28, 2020, 1:28am UTC](https://discourse.mc-stan.org/t/error-with-bayesian-workflow-for-disease-transmission-tutorial/16253/3 "2020-06-28T01:28:35Z")

</div>

@charlesm93

---

<div class="post-metadata">

**Author:** ![Ian.Frankenburg](https://avatars.discourse-cdn.com/v4/letter/i/b4bc9f/32.png) [@Ian.Frankenburg](https://discourse.mc-stan.org/u/Ian.Frankenburg)\
**Post date:** [June 28, 2020, 5:16pm UTC](https://discourse.mc-stan.org/t/error-with-bayesian-workflow-for-disease-transmission-tutorial/16253/4 "2020-06-28T17:16:01Z")

</div>

Yep, that’s right where I have the problem. I’ve noticed if I comment out the line

```
cases ~ neg_binomial_2(col(to_matrix(y), 2), phi);

```

within the “sir\_negbin.stan” file I don’t have an issue

---

<div class="post-metadata">

**Author:** ![Ian.Frankenburg](https://avatars.discourse-cdn.com/v4/letter/i/b4bc9f/32.png) [@Ian.Frankenburg](https://discourse.mc-stan.org/u/Ian.Frankenburg)\
**Post date:** [June 28, 2020, 5:40pm UTC](https://discourse.mc-stan.org/t/error-with-bayesian-workflow-for-disease-transmission-tutorial/16253/5 "2020-06-28T17:40:01Z")

</div>

I’ve solved the issue, in case anybody runs into this in the future.  
I can’t believe I didn’t try this earlier, but I hadn’t installed the latest release of R (version 4.0.2 ). I did that and reinstalled rstan, and now everything is working.
