# Stan model

**URL:** <https://discourse.mc-stan.org/t/stan-model/15663>\
**Category:** General\
**Created:** [June 4, 2020, 5:47pm UTC](https://discourse.mc-stan.org/t/stan-model/15663 "2020-06-04T17:47:15Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![spot2020](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@spot2020](https://discourse.mc-stan.org/u/spot2020)\
**Post date:** [June 4, 2020, 5:47pm UTC](https://discourse.mc-stan.org/t/stan-model/15663/1 "2020-06-04T17:47:15Z")

</div>

Can you please help I am trying to run the script but the program aborts  
The error message is  
Error in compileCode(f, code, language = language, verbose = verbose) : Compilation ERROR, function(s)/method(s) not created! file4248353f3ad7.cpp:6:36: warning: ISO C99 requires whitespace after the macro name #define STAN\_\_SERVICES\_\_COMMAND\_HPP#include \<boost/integer/integer\_log2.hpp\> ^ file4248353f3ad7.cpp:33:40: error: expected template-name before ‘\<’ token : public stan::model::model\_base\_crtp\<model424843e9427a\_974aa441eafec1bb4df62c61c118f4b9\> { ^ file4248353f3ad7.cpp:33:40: error: expected ‘{’ before ‘\<’ token file4248353f3ad7.cpp:33:40: error: expected unqualified-id before ‘\<’ token file4248353f3ad7.cpp:515:1: error: expected ‘}’ at end of input } ^ make: \*\*\* [C:/PROGRA~1/R/R-36~1.0/etc/x64/Makeconf:215: file4248353f3ad7.o] Error 1

---

<div class="post-metadata">

**Author:** ![andrjohns](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/andrjohns/32/15297_2.png) [@andrjohns](https://discourse.mc-stan.org/u/andrjohns)\
**Post date:** [June 5, 2020, 12:42am UTC](https://discourse.mc-stan.org/t/stan-model/15663/2 "2020-06-05T00:42:29Z")

</div>

Can you run:

```
example(stan_model,run.dontrun = TRUE,verbose=TRUE)

```

And post the line that starts with `error:`?

---

<div class="post-metadata">

**Author:** ![spot2020](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@spot2020](https://discourse.mc-stan.org/u/spot2020)\
**Post date:** [June 5, 2020, 7:10am UTC](https://discourse.mc-stan.org/t/stan-model/15663/3 "2020-06-05T07:10:38Z")

</div>

Thanks for your interest on helping me  
When I try to run the code it appears  
Building R package from source requires installation of additional build tools  
Do you want to install additional tools now?  
And the error  
Error in compileCode(f, code, language = language, verbose = verbose) :  
Compilation ERROR, function(s)/method(s) not created! file32c43fc36e32.cpp:6:36: warning: ISO C99 requires whitespace after the macro name  
#define STAN\_\_SERVICES\_\_COMMAND\_HPP#include \<boost/integer/integer\_log2.hpp\>  
^  
file32c43fc36e32.cpp:33:40: error: expected template-name before ‘\<’ token  
: public stan::model::model\_base\_crtp\<model32c429612e54\_73fc79f8b1915e8208c736914c86d1a1\> {  
^  
file32c43fc36e32.cpp:33:40: error: expected ‘{’ before ‘\<’ token  
file32c43fc36e32.cpp:33:40: error: expected unqualified-id before ‘\<’ token  
file32c43fc36e32.cpp:371:1: error: expected ‘}’ at end of input  
}  
^  
make: \*\*\* [C:/PROGRA~1/R/R-36~1.0/etc/x64/Makeconf:215: file32c43fc36e32.o] Error 1  
In addition: Warning message:  
In find.package(package, lib.loc, verbose = verbose) :  
package ‘base’ found more than once, using the first from  
“C:/PROGRA~1/R/R-36~1.0/library/base”,  
“C:/Program Files/R/R-3.6.0/library/base”  
When I click on No and try to run `example(stan_model,run.dontrun = TRUE,verbose=TRUE`  
The same message appears

---

<div class="post-metadata">

**Author:** ![andrjohns](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/andrjohns/32/15297_2.png) [@andrjohns](https://discourse.mc-stan.org/u/andrjohns)\
**Post date:** [June 5, 2020, 7:35am UTC](https://discourse.mc-stan.org/t/stan-model/15663/4 "2020-06-05T07:35:28Z")

</div>

Do you have RTools 3.5 installed and you’ve gone through the Installation guide on the wiki: [https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started](https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started)?

---

<div class="post-metadata">

**Author:** ![spot2020](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@spot2020](https://discourse.mc-stan.org/u/spot2020)\
**Post date:** [June 5, 2020, 8:28am UTC](https://discourse.mc-stan.org/t/stan-model/15663/5 "2020-06-05T08:28:01Z")

</div>

Hello  
I have installed the latest version of Rtools  
I tried to run again your script and I have got another error message  
Error in compileCode(f, code, language = language, verbose = verbose) :  
Compilation ERROR, function(s)/method(s) not created! g++.exe: error: Figueiredo/Documents/R/win-library/3.6/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp: No such file or directory  
make: \*\*\* [C:/PROGRA~1/R/R-36~1.0/etc/x64/Makeconf:215: file4ac08b77d4d.o] Error 1  
In addition: Warning message:  
In find.package(package, lib.loc, verbose = verbose) :  
package ‘base’ found more than once, using the first from  
“C:/PROGRA~1/R/R-36~1.0/library/base”,  
“C:/Program Files/R/R-3.6.0/library/base”

---

<div class="post-metadata">

**Author:** ![andrjohns](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/andrjohns/32/15297_2.png) [@andrjohns](https://discourse.mc-stan.org/u/andrjohns)\
**Post date:** [June 5, 2020, 8:56am UTC](https://discourse.mc-stan.org/t/stan-model/15663/6 "2020-06-05T08:56:28Z")

</div>

Great, that’s good progress! That means that version of the StanHeaders packages has gotten ahead of the version of the rstan package. To fix that error, you need to remove rstan and stanheaders:

```
remove.packages(c("rstan","StanHeaders"))

```

Then restart R and run:

```
install.packages("https://cran.r-project.org/src/contrib/Archive/StanHeaders/StanHeaders_2.19.2.tar.gz", type="source",repos=NULL)
install.packages("rstan")

```

Then test if the installation has worked:

```
library(rstan)
example(stan_model,run.dontrun = TRUE,verbose=TRUE)

```

---

<div class="post-metadata">

**Author:** ![spot2020](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@spot2020](https://discourse.mc-stan.org/u/spot2020)\
**Post date:** [June 5, 2020, 9:04am UTC](https://discourse.mc-stan.org/t/stan-model/15663/7 "2020-06-05T09:04:03Z")

</div>

Unfortenatly the error persist  
Error in compileCode(f, code, language = language, verbose = verbose) :  
Compilation ERROR, function(s)/method(s) not created! file4268566a430e.cpp:6:36: warning: ISO C99 requires whitespace after the macro name  
#define STAN\_\_SERVICES\_\_COMMAND\_HPP#include \<boost/integer/integer\_log2.hpp\>  
^  
file4268566a430e.cpp:33:40: error: expected template-name before ‘\<’ token  
: public stan::model::model\_base\_crtp\<model426816d875c0\_73fc79f8b1915e8208c736914c86d1a1\> {  
^  
file4268566a430e.cpp:33:40: error: expected ‘{’ before ‘\<’ token  
file4268566a430e.cpp:33:40: error: expected unqualified-id before ‘\<’ token  
file4268566a430e.cpp:371:1: error: expected ‘}’ at end of input  
}  
^  
make: \*\*\* [C:/PROGRA~1/R/R-36~1.0/etc/x64/Makeconf:215: file4268566a430e.o] Error 1  
In addition: Warning message:  
In find.package(package, lib.loc, verbose = verbose) :  
package ‘base’ found more than once, using the first from  
“C:/PROGRA~1/R/R-36~1.0/library/base”,  
“C:/Program Files/R/R-3.6.0/library/base”

---

<div class="post-metadata">

**Author:** ![andrjohns](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/andrjohns/32/15297_2.png) [@andrjohns](https://discourse.mc-stan.org/u/andrjohns)\
**Post date:** [June 5, 2020, 9:32am UTC](https://discourse.mc-stan.org/t/stan-model/15663/8 "2020-06-05T09:32:14Z")

</div>

What’s the output of:

```
readLines("~/.R/Makevars.win")

```

---

<div class="post-metadata">

**Author:** ![spot2020](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@spot2020](https://discourse.mc-stan.org/u/spot2020)\
**Post date:** [June 5, 2020, 9:36am UTC](https://discourse.mc-stan.org/t/stan-model/15663/9 "2020-06-05T09:36:55Z")

</div>

The output is  
[1] “” “CXX14FLAGS=-O3 -march=native -mtune=native”  
[3] “CXX11FLAGS=-O3 -march=corei7 -mtune=corei7” “”  
[5] “CXX14FLAGS=-O3 -march=native -mtune=native” “CXX11FLAGS=-O3 -march=corei7 -mtune=corei7”  
[7] “” “CXX14FLAGS=-O3 -march=native -mtune=native”  
[9] “CXX11FLAGS=-O3 -march=corei7 -mtune=corei7”

---

<div class="post-metadata">

**Author:** ![andrjohns](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/andrjohns/32/15297_2.png) [@andrjohns](https://discourse.mc-stan.org/u/andrjohns)\
**Post date:** [June 5, 2020, 9:45am UTC](https://discourse.mc-stan.org/t/stan-model/15663/10 "2020-06-05T09:45:26Z")

</div>

Could you also re-run the example model:

```
example(stan_model,run.dontrun = TRUE,verbose=TRUE)

```

And copy the section after `Compilation argument:`? For example, on my machine this looks like:

```
Compilation argument:
 C:/PROGRA~1/R/R-40~1.0/bin/x64/R CMD SHLIB filebb82f5a2ce.cpp 2> filebb82f5a2ce.cpp.err.txt 
"C:/rtools40/mingw64/bin/"g++ -std=gnu++14 -I"C:/PROGRA~1/R/R-40~1.0/include" -DNDEBUG -I"C:/Users/Andrew Johnson/Documents/R/win-library/4.0/Rcpp/include/" -I"C:/Users/Andrew Johnson/Documents/R/win-library/4.0/RcppEigen/include/" -I"C:/Users/Andrew Johnson/Documents/R/win-library/4.0/RcppEigen/include/unsupported" -I"C:/Users/Andrew Johnson/Documents/R/win-library/4.0/BH/include" -I"C:/Users/Andrew Johnson/Documents/R/win-library/4.0/StanHeaders/include/src/" -I"C:/Users/Andrew Johnson/Documents/R/win-library/4.0/StanHeaders/include/" -I"C:/Users/Andrew Johnson/Documents/R/win-library/4.0/rstan/include" -DEIGEN_NO_DEBUG -D_REENTRANT -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -include stan/math/prim/mat/fun/Eigen.hpp -std=c++1y -march=core2 -O3 -Wno-unused-variable -Wno-unused-function -std=c++14 -march=native -mtune=native -Wno-deprecated-declarations -Wno-ignored-attributes -c filebb82f5a2ce.cpp -o filebb82f5a2ce.o

```

Just to see if there are any misconfigurations or missing compiler flags that `RStan` needs

---

<div class="post-metadata">

**Author:** ![spot2020](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@spot2020](https://discourse.mc-stan.org/u/spot2020)\
**Post date:** [June 5, 2020, 9:54am UTC](https://discourse.mc-stan.org/t/stan-model/15663/11 "2020-06-05T09:54:59Z")

</div>

Error in compileCode(f, code, language = language, verbose = verbose) :  
Compilation ERROR, function(s)/method(s) not created! filec2c2ebc5e81.cpp:6:36: warning: ISO C99 requires whitespace after the macro name  
#define STAN\_\_SERVICES\_\_COMMAND\_HPP#include \<boost/integer/integer\_log2.hpp\>  
^  
filec2c2ebc5e81.cpp:33:40: error: expected template-name before ‘\<’ token  
: public stan::model::model\_base\_crtp\<modelc2c40a157e9\_73fc79f8b1915e8208c736914c86d1a1\> {  
^  
filec2c2ebc5e81.cpp:33:40: error: expected ‘{’ before ‘\<’ token  
filec2c2ebc5e81.cpp:33:40: error: expected unqualified-id before ‘\<’ token  
filec2c2ebc5e81.cpp:371:1: error: expected ‘}’ at end of input  
}  
^  
make: \*\*\* [C:/PROGRA~1/R/R-36~1.0/etc/x64/Makeconf:215: filec2c2ebc5e81.o] Error 1  
In addition: Warning message:  
In find.package(package, lib.loc, verbose = verbose) :  
package ‘base’ found more than once, using the first from  
“C:/PROGRA~1/R/R-36~1.0/library/base”,  
“C:/Program Files/R/R-3.6.0/library/base”

---

<div class="post-metadata">

**Author:** ![andrjohns](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/andrjohns/32/15297_2.png) [@andrjohns](https://discourse.mc-stan.org/u/andrjohns)\
**Post date:** [June 5, 2020, 10:02am UTC](https://discourse.mc-stan.org/t/stan-model/15663/12 "2020-06-05T10:02:45Z")

</div>

I need the section that starts with `Compilation argument:`, like the example I posted above

---

<div class="post-metadata">

**Author:** ![spot2020](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@spot2020](https://discourse.mc-stan.org/u/spot2020)\
**Post date:** [June 5, 2020, 10:13am UTC](https://discourse.mc-stan.org/t/stan-model/15663/13 "2020-06-05T10:13:45Z")

</div>

Sorry  
Compilation argument:  
C:/PROGRA~1/R/R-36~1.0/bin/x64/R CMD SHLIB filec2c2f36ad2.cpp 2\> filec2c2f36ad2.cpp.err.txt  
C:/Rtools/mingw\_64/bin/g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-36~1.0/include" -DNDEBUG -I"C:/Users/Ivone Figueiredo/Documents/R/win-library/3.6/Rcpp/include/" -I"C:/Users/Ivone Figueiredo/Documents/R/win-library/3.6/RcppEigen/include/" -I"C:/Users/Ivone Figueiredo/Documents/R/win-library/3.6/RcppEigen/include/unsupported" -I"C:/Users/Ivone Figueiredo/Documents/R/win-library/3.6/BH/include" -I"C:/Users/Ivone Figueiredo/Documents/R/win-library/3.6/StanHeaders/include/src/" -I"C:/Users/Ivone Figueiredo/Documents/R/win-library/3.6/StanHeaders/include/" -I"C:/Users/Ivone Figueiredo/Documents/R/win-library/3.6/rstan/include" -DEIGEN\_NO\_DEBUG -D\_REENTRANT -DBOOST\_DISABLE\_ASSERTS -DBOOST\_PENDING\_INTEGER\_LOG2\_HPP -include stan/math/prim/mat/fun/Eigen.hpp -std=c++1y -march=core2 -O3 -march=corei7 -mtune=corei7 -c filec2c2f36ad2.cpp -o filec2c2f36ad2.o  
filec2c2f36ad2.cpp:6:36: warning: ISO C99 requires whitespace after the macro name  
#define STAN\_\_SERVICES\_\_COMMAND\_HPP#include \<boost/integer/integer\_log2.hpp\>  
^  
filec2c2f36ad2.cpp:33:40: error: expected template-name before ‘\<’ token  
: public stan::model::model\_base\_crtp\<modelc2c20ca56ec\_73fc79f8b1915e8208c736914c86d1a1\> {  
^  
filec2c2f36ad2.cpp:33:40: error: expected ‘{’ before ‘\<’ token  
filec2c2f36ad2.cpp:33:40: error: expected unqualified-id before ‘\<’ token  
filec2c2f36ad2.cpp:371:1: error: expected ‘}’ at end of input  
}  
^  
make: \*\*\* [C:/PROGRA~1/R/R-36~1.0/etc/x64/Makeconf:215: filec2c2f36ad2.o] Error 1

ERROR(s) during compilation: source code errors or compiler configuration errors!

---

<div class="post-metadata">

**Author:** ![andrjohns](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/andrjohns/32/15297_2.png) [@andrjohns](https://discourse.mc-stan.org/u/andrjohns)\
**Post date:** [June 5, 2020, 2:03pm UTC](https://discourse.mc-stan.org/t/stan-model/15663/14 "2020-06-05T14:03:45Z")

</div>

Hmm, I’m afraid I can’t see anything wrong with your setup sorry.

You might have better luck with @bgoodri here

---

<div class="post-metadata">

**Author:** ![spot2020](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@spot2020](https://discourse.mc-stan.org/u/spot2020)\
**Post date:** [June 5, 2020, 3:47pm UTC](https://discourse.mc-stan.org/t/stan-model/15663/15 "2020-06-05T15:47:32Z")

</div>

thank you very for your help  
How I can address @bgoodri h

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [June 6, 2020, 2:12am UTC](https://discourse.mc-stan.org/t/stan-model/15663/16 "2020-06-06T02:12:00Z")

</div>

What is `packageVersion("rstan")`?

---

<div class="post-metadata">

**Author:** ![spot2020](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@spot2020](https://discourse.mc-stan.org/u/spot2020)\
**Post date:** [June 6, 2020, 7:05am UTC](https://discourse.mc-stan.org/t/stan-model/15663/17 "2020-06-06T07:05:29Z")

</div>

Good morning  
Rstan is a package allows one to conveniently fit Stan models from R (R Core Team 2014) and access the output, including posterior inferences and intermediate quantities such as evaluations of the log posterior density and its gradients [RStan-Getting-Started](https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started).  
THanks
