# Specifying include\_paths in rstan

**URL:** https://discourse.mc-stan.org/t/specifying-include-paths-in-rstan/32182
**Category:** RStan
**Tags:** specification
**Created:** [July 20, 2023, 11:52pm UTC](https://discourse.mc-stan.org/t/specifying-include-paths-in-rstan/32182 "2023-07-20T23:52:02Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![chris1](https://avatars.discourse-cdn.com/v4/letter/c/ac91a4/32.png) [@chris1](https://discourse.mc-stan.org/u/chris1)
#### Post date: [July 20, 2023, 11:52pm UTC](https://discourse.mc-stan.org/t/specifying-include-paths-in-rstan/32182/1 "2023-07-20T23:52:02Z")

</div>

Hi,

Hopefully an easy answer to this question here, but I have been trawling the docs and forum for a while now and haven’t found an answer.

How does one specify `include_paths` in rstan? In cmdstanr it is easy, something like this works fine:  
`cmdstan_model(stanfile, include_paths=c("/mnt", functions_path))`

but I can’t figure out how to do this in rstan.

The reason why I can’t define all my extra functions relative to `/mnt` in the stan file is because I have a few dozen models (as an ensemble) where the “base model” is the same, with the following include statement: `#include extra_functions.stan`.

I have many different versions of extra\_functions.stan, located in different directories. This way I can fit many different versions of models without duplicating rather complex stan model code. To fit a different model in the ensemble, all I need to do is change the `functions_path` variable when I set `include_paths`. This method works fine in cmdstanr, but I can’t figure out how to implement in rstan.

Many thanks  
Chris

---

<div class="post-metadata">

### Author: ![Bob\_Carpenter](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bob_carpenter/32/9230_2.png) [@Bob\_Carpenter](https://discourse.mc-stan.org/u/Bob_Carpenter)
#### Post date: [July 27, 2023, 10:00pm UTC](https://discourse.mc-stan.org/t/specifying-include-paths-in-rstan/32182/2 "2023-07-27T22:00:33Z")

</div>

There does not appear to be an argument to do this, so I think you just need absolute paths.

> **[Fit a model with Stan — stan](https://mc-stan.org/rstan/reference/stan.html)**
>
> Fit a model defined in the Stan modeling language and  
> return the fitted result as an instance of stanfit.

See the previous thread from 5 years ago. [How to specify include path when compiling stan models?](https://discourse.mc-stan.org/t/how-to-specify-include-path-when-compiling-stan-models/3764)

@bgoodri should know if there’s a better option now.
