# Rstan install trouble

**URL:** <https://discourse.mc-stan.org/t/rstan-install-trouble/19078>\
**Category:** RStan\
**Tags:** installation\
**Created:** [November 5, 2020, 12:21am UTC](https://discourse.mc-stan.org/t/rstan-install-trouble/19078 "2020-11-05T00:21:41Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![dr-jojo](https://avatars.discourse-cdn.com/v4/letter/d/f08c70/32.png) [@dr-jojo](https://discourse.mc-stan.org/u/dr-jojo)\
**Post date:** [November 5, 2020, 12:21am UTC](https://discourse.mc-stan.org/t/rstan-install-trouble/19078/1 "2020-11-05T00:21:41Z")

</div>

I was working with Stan, particularly brms and the rethinking package and was able to get it to install and run. However, I went to run some models and cannot get it to work now. I have tried uninstalling all R programs multiple times and then following the instructions for installing Stan. It keeps giving me the exact same error. See below. Any help would be appreciated.

Error in withr::set\_makevars(new, path, state, assignment = assignment) :  
Multiple results for CXX14FLAGS found, something is wrong.FALSE  
In addition: Warning message:  
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :  
‘C:/rtools40/usr/mingw\_/bin/g++’ not found

---

<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:** [November 5, 2020, 12:33am UTC](https://discourse.mc-stan.org/t/rstan-install-trouble/19078/2 "2020-11-05T00:33:28Z")

</div>

Hi Jojo,

Sorry that this is causing you so much trouble! The problem is that your `Makevars.win` file has multiple entries for the `CXX14FLAGS` option. The current version of `rstan` is having some problems with the Makevars file on Windows, so it will be easiest to just rename the file and run without one until the issue is fixed.

Try running:

```
file.rename("~/.R/Makevars.win", "~/.R/Makevars.win.bak")

```

Then restart R and try your model again

---

<div class="post-metadata">

**Author:** ![dr-jojo](https://avatars.discourse-cdn.com/v4/letter/d/f08c70/32.png) [@dr-jojo](https://discourse.mc-stan.org/u/dr-jojo)\
**Post date:** [November 5, 2020, 12:45am UTC](https://discourse.mc-stan.org/t/rstan-install-trouble/19078/3 "2020-11-05T00:45:14Z")

</div>

Cool, thank you! I think that might have solved it. I still get the warning message below, but I think I can ignore that if I read the install instructions right.

Warning message:  
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :  
‘C:/rtools40/usr/mingw\_/bin/g++’ not found

But when I try to run a model on brms it starts to sample and then I get the following message:

Start sampling  
Error in unserialize(socklist[[n]]) : error reading from connection  
In addition: Warning message:  
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :  
‘C:/rtools40/usr/mingw\_/bin/g++’ not found  
Error in serialize(data, node$con, xdr = FALSE) :  
error writing to connection

---

<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:** [November 5, 2020, 12:49am UTC](https://discourse.mc-stan.org/t/rstan-install-trouble/19078/4 "2020-11-05T00:49:16Z")

</div>

Progress is good at least! To debug this, I’ll need a little more information.

Can you post the output from:

```
Sys.getenv("PATH")
Sys.getenv("BINPREF")
readLines("~/.Rprofile")
readLines("~/.Renviron")
devtools::session_info("rstan")

```

---

<div class="post-metadata">

**Author:** ![dr-jojo](https://avatars.discourse-cdn.com/v4/letter/d/f08c70/32.png) [@dr-jojo](https://discourse.mc-stan.org/u/dr-jojo)\
**Post date:** [November 5, 2020, 12:54am UTC](https://discourse.mc-stan.org/t/rstan-install-trouble/19078/5 "2020-11-05T00:54:28Z")

</div>

> Sys.getenv(“BINPREF”)  
> [1] “”  
> readLines(“~/.Rprofile”)  
> Error in file(con, “r”) : cannot open the connection  
> In addition: Warning message:  
> In file(con, “r”) :  
> cannot open file ‘C:/Users/JoJo/Documents/.Rprofile’: No such file or directory  
> readLines(“~/.Renviron”)  
> [1] “PATH="{RTOOLS40\_HOME}\\usr\\bin;{PATH}"”  
> devtools::session\_info(“rstan”)

- Session info -----------------------------------------------------------------------------------------------------------------------  
setting value  
version R version 4.0.3 (2020-10-10)  
os Windows 10 x64  
system x86\_64, mingw32  
ui RStudio  
language (EN)  
collate English\_United States.1252  
ctype English\_United States.1252  
tz America/New\_York  
date 2020-11-04

- Packages ---------------------------------------------------------------------------------------------------------------------------  
! package \* version date lib source  
assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.3)  
backports 1.1.10 2020-09-15 [1] CRAN (R 4.0.3)  
BH 1.72.0-3 2020-01-08 [1] CRAN (R 4.0.3)  
callr 3.5.1 2020-10-13 [1] CRAN (R 4.0.3)  
checkmate 2.0.0 2020-02-06 [1] CRAN (R 4.0.3)  
cli 2.1.0 2020-10-12 [1] CRAN (R 4.0.3)  
colorspace 1.4-1 2019-03-18 [1] CRAN (R 4.0.3)  
crayon 1.3.4 2017-09-16 [1] CRAN (R 4.0.3)  
curl 4.3 2019-12-02 [1] CRAN (R 4.0.3)  
desc 1.2.0 2018-05-01 [1] CRAN (R 4.0.3)  
digest 0.6.27 2020-10-24 [1] CRAN (R 4.0.3)  
ellipsis 0.3.1 2020-05-15 [1] CRAN (R 4.0.3)  
evaluate 0.14 2019-05-28 [1] CRAN (R 4.0.3)  
fansi 0.4.1 2020-01-08 [1] CRAN (R 4.0.3)  
farver 2.0.3 2020-01-16 [1] CRAN (R 4.0.3)  
ggplot2 \* 3.3.2 2020-06-19 [1] CRAN (R 4.0.3)  
glue 1.4.2 2020-08-27 [1] CRAN (R 4.0.3)  
gridExtra 2.3 2017-09-09 [1] CRAN (R 4.0.3)  
gtable 0.3.0 2019-03-25 [1] CRAN (R 4.0.3)  
inline 0.3.16 2020-09-06 [1] CRAN (R 4.0.3)  
isoband 0.2.2 2020-06-20 [1] CRAN (R 4.0.3)  
jsonlite 1.7.1 2020-09-07 [1] CRAN (R 4.0.3)  
labeling 0.4.2 2020-10-20 [1] CRAN (R 4.0.3)  
lattice 0.20-41 2020-04-02 [2] CRAN (R 4.0.3)  
lifecycle 0.2.0 2020-03-06 [1] CRAN (R 4.0.3)  
loo 2.3.1 2020-07-14 [1] CRAN (R 4.0.3)  
magrittr 1.5 2014-11-22 [1] CRAN (R 4.0.3)  
MASS 7.3-53 2020-09-09 [2] CRAN (R 4.0.3)  
Matrix 1.2-18 2019-11-27 [2] CRAN (R 4.0.3)  
matrixStats 0.57.0 2020-09-25 [1] CRAN (R 4.0.3)  
mgcv 1.8-33 2020-08-27 [2] CRAN (R 4.0.3)  
munsell 0.5.0 2018-06-12 [1] CRAN (R 4.0.3)  
nlme 3.1-149 2020-08-23 [2] CRAN (R 4.0.3)  
pillar 1.4.6 2020-07-10 [1] CRAN (R 4.0.3)  
pkgbuild 1.1.0 2020-07-13 [1] CRAN (R 4.0.3)  
pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.3)  
pkgload 1.1.0 2020-05-29 [1] CRAN (R 4.0.3)  
praise 1.0.0 2015-08-11 [1] CRAN (R 4.0.3)  
prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.0.3)  
processx 3.4.4 2020-09-03 [1] CRAN (R 4.0.3)  
ps 1.4.0 2020-10-07 [1] CRAN (R 4.0.3)  
R6 2.5.0 2020-10-28 [1] CRAN (R 4.0.3)  
RColorBrewer 1.1-2 2014-12-07 [1] CRAN (R 4.0.3)  
Rcpp \* 1.0.5 2020-07-06 [1] CRAN (R 4.0.3)  
RcppEigen 0.3.3.7.0 2019-11-16 [1] CRAN (R 4.0.3)  
D RcppParallel 5.0.2 2020-06-24 [1] CRAN (R 4.0.3)  
rlang 0.4.8 2020-10-08 [1] CRAN (R 4.0.3)  
rprojroot 1.3-2 2018-01-03 [1] CRAN (R 4.0.3)  
rstan \* 2.21.2 2020-07-27 [1] CRAN (R 4.0.3)  
rstudioapi 0.11 2020-02-07 [1] CRAN (R 4.0.3)  
scales 1.1.1 2020-05-11 [1] CRAN (R 4.0.3)  
StanHeaders \* 2.21.0-6 2020-08-16 [1] CRAN (R 4.0.3)  
testthat 2.3.2 2020-03-02 [1] CRAN (R 4.0.3)  
tibble 3.0.4 2020-10-12 [1] CRAN (R 4.0.3)  
utf8 1.1.4 2018-05-24 [1] CRAN (R 4.0.3)  
V8 3.3.1 2020-10-26 [1] CRAN (R 4.0.3)  
vctrs 0.3.4 2020-08-29 [1] CRAN (R 4.0.3)  
viridisLite 0.3.0 2018-02-01 [1] CRAN (R 4.0.3)  
withr 2.3.0 2020-09-22 [1] CRAN (R 4.0.3)

[1] C:/Users/JoJo/Documents/R/win-library/4.0  
[2] C:/Program Files/R/R-4.0.3/library

D – DLL MD5 mismatch, broken installation.

---

<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:** [November 5, 2020, 12:56am UTC](https://discourse.mc-stan.org/t/rstan-install-trouble/19078/6 "2020-11-05T00:56:01Z")

</div>

Alright, that all looks good. Do you get the same error with the rstan example model?

Try running:

```
example(stan_model,run.dontrun=T)

```

---

<div class="post-metadata">

**Author:** ![dr-jojo](https://avatars.discourse-cdn.com/v4/letter/d/f08c70/32.png) [@dr-jojo](https://discourse.mc-stan.org/u/dr-jojo)\
**Post date:** [November 5, 2020, 12:57am UTC](https://discourse.mc-stan.org/t/rstan-install-trouble/19078/7 "2020-11-05T00:57:10Z")

</div>

Now I am getting:

Warning messages:  
1: In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :  
‘C:/rtools40/usr/mingw\_/bin/g++’ not found  
2: In for (i in 1:n) { :  
closing unused connection 6 (\<-view-localhost:11841)  
3: In for (i in 1:n) { :  
closing unused connection 5 (\<-view-localhost:11841)  
4: In for (i in 1:n) { :  
closing unused connection 4 (\<-view-localhost:11841)  
5: In for (i in 1:n) { :  
closing unused connection 3 (\<-view-localhost:11841)

---

<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:** [November 5, 2020, 12:58am UTC](https://discourse.mc-stan.org/t/rstan-install-trouble/19078/8 "2020-11-05T00:58:28Z")

</div>

Those aren’t always a concern, they’re just child processes left over from running chains in parallel. Does the model sample and finish running?

---

<div class="post-metadata">

**Author:** ![dr-jojo](https://avatars.discourse-cdn.com/v4/letter/d/f08c70/32.png) [@dr-jojo](https://discourse.mc-stan.org/u/dr-jojo)\
**Post date:** [November 5, 2020, 1:18pm UTC](https://discourse.mc-stan.org/t/rstan-install-trouble/19078/9 "2020-11-05T13:18:58Z")

</div>

So I think I did get the example to run. I could see two fit objects and the mod object. But when I try to runs a brms model I get:

Compiling Stan program…  
Start sampling  
Error in unserialize(socklist[[n]]) : error reading from connection  
In addition: Warning message:  
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :  
‘C:/rtools40/usr/mingw\_/bin/g++’ not found  
Error in serialize(data, node$con, xdr = FALSE) :  
error writing to connection

---

<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:** [November 6, 2020, 12:25pm UTC](https://discourse.mc-stan.org/t/rstan-install-trouble/19078/10 "2020-11-06T12:25:53Z")

</div>

Alright, so it looks like there’s a brms issue. Can you try running a `brms` example model:

```
library(brms)
brm(formula = time | cens(censored) ~ age * sex + disease 
               + (1 + age|patient), cores = 4,
               data = kidney, family = lognormal(),
               prior = c(set_prior("normal(0,5)", class = "b"),
                         set_prior("cauchy(0,2)", class = "sd"),
                         set_prior("lkj(2)", class = "cor")))

```

---

<div class="post-metadata">

**Author:** ![dr-jojo](https://avatars.discourse-cdn.com/v4/letter/d/f08c70/32.png) [@dr-jojo](https://discourse.mc-stan.org/u/dr-jojo)\
**Post date:** [November 6, 2020, 1:23pm UTC](https://discourse.mc-stan.org/t/rstan-install-trouble/19078/11 "2020-11-06T13:23:59Z")

</div>

So when I run that, it also does not work. This is what I get:

Compiling Stan program…  
recompiling to avoid crashing R session  
Start sampling  
Error in unserialize(socklist[[n]]) : error reading from connection  
In addition: Warning message:  
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :  
‘C:/rtools40/usr/mingw\_/bin/g++’ not found  
Error in serialize(data, node$con, xdr = FALSE) :  
error writing to connection

---

<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:** [November 6, 2020, 1:38pm UTC](https://discourse.mc-stan.org/t/rstan-install-trouble/19078/12 "2020-11-06T13:38:55Z")

</div>

Do you get a different output with the `chains=1` and `verbose=T` options?

---

<div class="post-metadata">

**Author:** ![dr-jojo](https://avatars.discourse-cdn.com/v4/letter/d/f08c70/32.png) [@dr-jojo](https://discourse.mc-stan.org/u/dr-jojo)\
**Post date:** [November 6, 2020, 2:45pm UTC](https://discourse.mc-stan.org/t/rstan-install-trouble/19078/13 "2020-11-06T14:45:29Z")

</div>

So when I try the chains =1, R just crashes. Using verbose = T, it starts to run but I get a similar error.

Compiling Stan program…  
Start sampling

CHECKING DATA AND PREPROCESSING FOR MODEL ‘1e678f39ae8dd1a9aa449ac57e3cc8a9’ NOW.

COMPILING MODEL ‘1e678f39ae8dd1a9aa449ac57e3cc8a9’ NOW.

STARTING SAMPLER FOR MODEL ‘1e678f39ae8dd1a9aa449ac57e3cc8a9’ NOW.  
Error in unserialize(socklist[[n]]) : error reading from connection  
In addition: Warning message:  
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :  
‘C:/rtools40/usr/mingw\_/bin/g++’ not found  
Error in serialize(data, node$con, xdr = FALSE) :  
error writing to connection

---

<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:** [November 6, 2020, 2:56pm UTC](https://discourse.mc-stan.org/t/rstan-install-trouble/19078/14 "2020-11-06T14:56:37Z")

</div>

Hmm can you restart R and post the output from:

```
mod = "data{real y_mean;} parameters{real y;} model{y~normal(y_mean,1);}"
rstan::stan(model_code=mod,data=list(y_mean=0),chains=1,verbose=T)

```

---

<div class="post-metadata">

**Author:** ![dr-jojo](https://avatars.discourse-cdn.com/v4/letter/d/f08c70/32.png) [@dr-jojo](https://discourse.mc-stan.org/u/dr-jojo)\
**Post date:** [November 6, 2020, 3:06pm UTC](https://discourse.mc-stan.org/t/rstan-install-trouble/19078/15 "2020-11-06T15:06:40Z")

</div>

First it says

TRANSLATING MODEL ‘efb77423d7adb44255913eac3d9377e8’ FROM Stan CODE TO C++ CODE NOW.  
successful in parsing the Stan model ‘efb77423d7adb44255913eac3d9377e8’.  
COMPILING THE C++ CODE FOR MODEL ‘efb77423d7adb44255913eac3d9377e8’ NOW.  
OS: x86\_64, mingw32; rstan: 2.21.2; Rcpp: 1.0.5; inline: 0.3.16

> > setting environment variables:  
> > LOCAL\_LIBS = “C:/Users/JoJo/Documents/R/win-library/4.0/rstan/lib/x64/libStanServices.a” -L"C:/Users/JoJo/Documents/R/win-library/4.0/StanHeaders/libs/x64" -lStanHeaders -L"C:/Users/JoJo/Documents/R/win-library/4.0/RcppParallel/lib/x64" -ltbb  
> > PKG\_CPPFLAGS = -I"C:/Users/JoJo/Documents/R/win-library/4.0/Rcpp/include/" -I"C:/Users/JoJo/Documents/R/win-library/4.0/RcppEigen/include/" -I"C:/Users/JoJo/Documents/R/win-library/4.0/RcppEigen/include/unsupported" -I"C:/Users/JoJo/Documents/R/win-library/4.0/BH/include" -I"C:/Users/JoJo/Documents/R/win-library/4.0/StanHeaders/include/src/" -I"C:/Users/JoJo/Documents/R/win-library/4.0/StanHeaders/include/" -I"C:/Users/JoJo/Documents/R/win-library/4.0/RcppParallel/include/" -I"C:/Users/JoJo/Documents/R/win-library/4.0/rstan/include" -DEIGEN\_NO\_DEBUG -DBOOST\_DISABLE\_ASSERTS -DBOOST\_PENDING\_INTEGER\_LOG2\_HPP -DSTAN\_THREADS -DBOOST\_NO\_AUTO\_PTR -include “C:/Users/JoJo/Documents/R/win-library/4.0/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp” -std=c++1y

---

<div class="post-metadata">

**Author:** ![dr-jojo](https://avatars.discourse-cdn.com/v4/letter/d/f08c70/32.png) [@dr-jojo](https://discourse.mc-stan.org/u/dr-jojo)\
**Post date:** [November 6, 2020, 3:08pm UTC](https://discourse.mc-stan.org/t/rstan-install-trouble/19078/16 "2020-11-06T15:08:04Z")

</div>

And then:

> > Program source :

1 :  
2 : // includes from the plugin  
3 : // [[Rcpp::plugins(cpp14)]]  
4 :  
5 :  
6 : // user includes  
7 : #include \<Rcpp.h\>  
8 : #include \<rstan/io/rlist\_ref\_var\_context.hpp\>  
9 : #include \<rstan/io/r\_ostream.hpp\>  
10 : #include \<rstan/stan\_args.hpp\>  
11 : #include \<boost/integer/integer\_log2.hpp\>  
12 : // Code generated by Stan version 2.21.0  
13 :  
14 : #include \<stan/model/model\_header.hpp\>  
15 :  
16 : namespace model242412b94d4b\_efb77423d7adb44255913eac3d9377e8\_namespace {  
17 :  
18 : using std::istream;  
19 : using std::string;  
20 : using std::stringstream;  
21 : using std::vector;  
22 : using stan::io::dump;  
23 : using stan::math::lgamma;  
24 : using stan::model::prob\_grad;  
25 : using namespace stan::math;  
26 :  
27 : static int current\_statement\_begin\_\_;  
28 :  
29 : stan::io::program\_reader prog\_reader\_\_() {  
30 : stan::io::program\_reader reader;  
31 : reader.add\_event(0, 0, “start”, “model242412b94d4b\_efb77423d7adb44255913eac3d9377e8”);  
32 : reader.add\_event(3, 1, “end”, “model242412b94d4b\_efb77423d7adb44255913eac3d9377e8”);  
33 : return reader;  
34 : }  
35 :  
36 : class model242412b94d4b\_efb77423d7adb44255913eac3d9377e8  
37 : : public stan::model::model\_base\_crtp\<model242412b94d4b\_efb77423d7adb44255913eac3d9377e8\> {  
38 : private:  
39 : double y\_mean;  
40 : public:  
41 : model242412b94d4b\_efb77423d7adb44255913eac3d9377e8(rstan::io::rlist\_ref\_var\_context& context\_\_,  
42 : std::ostream\* pstream\_\_ = 0)  
43 : : model\_base\_crtp(0) {  
44 : ctor\_body(context\_\_, 0, pstream\_\_);  
45 : }  
46 :  
47 : model242412b94d4b\_efb77423d7adb44255913eac3d9377e8(stan::io::var\_context& context\_\_,  
48 : unsigned int random\_seed\_\_,  
49 : std::ostream\* pstream\_\_ = 0)  
50 : : model\_base\_crtp(0) {  
51 : ctor\_body(context\_\_, random\_seed\_\_, pstream\_\_);  
52 : }  
53 :  
54 : void ctor\_body(stan::io::var\_context& context\_\_,  
55 : unsigned int random\_seed\_\_,  
56 : std::ostream\* pstream\_\_) {  
57 : typedef double local\_scalar\_t\_\_;  
58 :  
59 : boost::ecuyer1988 base\_rng\_\_ =  
60 : stan::services::util::create\_rng(random\_seed\_\_, 0);  
61 : (void) base\_rng\_\_; // suppress unused var warning  
62 :  
63 : current\_statement\_begin\_\_ = -1;  
64 :  
65 : static const char\* function\_\_ =

---

<div class="post-metadata">

**Author:** ![dr-jojo](https://avatars.discourse-cdn.com/v4/letter/d/f08c70/32.png) [@dr-jojo](https://discourse.mc-stan.org/u/dr-jojo)\
**Post date:** [November 6, 2020, 3:08pm UTC](https://discourse.mc-stan.org/t/rstan-install-trouble/19078/17 "2020-11-06T15:08:49Z")

</div>

66 : (void) function\_\_; // dummy to suppress unused var warning  
67 : size\_t pos\_\_;  
68 : (void) pos\_\_; // dummy to suppress unused var warning  
69 : std::vector vals\_i\_\_;  
70 : std::vector vals\_r\_\_;  
71 : local\_scalar\_t\_\_ DUMMY\_VAR\_\_(std::numeric\_limits::quiet\_NaN());  
72 : (void) DUMMY\_VAR\_\_; // suppress unused var warning  
73 :  
74 : try {  
75 : // initialize data block variables from context\_\_  
76 : current\_statement\_begin\_\_ = 1;  
77 : context\_\_.validate\_dims(“data initialization”, “y\_mean”, “double”, context\_\_.to\_vec());  
78 : y\_mean = double(0);  
79 : vals\_r\_\_ = context\_\_.vals\_r(“y\_mean”);  
80 : pos\_\_ = 0;  
81 : y\_mean = vals\_r\_\_[pos\_\_++];  
82 :  
83 :  
84 : // initialize transformed data variables  
85 : // execute transformed data statements  
86 :  
87 : // validate transformed data  
88 :  
89 : // validate, set parameter ranges  
90 : num\_params\_r\_\_ = 0U;  
91 : param\_ranges\_i\_\_.clear();  
92 : current\_statement\_begin\_\_ = 1;  
93 : num\_params\_r\_\_ += 1;  
94 : } catch (const std::exception& e) {  
95 : stan::lang::rethrow\_located(e, current\_statement\_begin\_\_, prog\_reader\_\_());  
96 : // Next line prevents compiler griping about no return  
97 : throw std::runtime\_error("\*\*\* IF YOU SEE THIS, PLEASE REPORT A BUG \*\*\*");  
98 : }  
99 : }  
100 :  
101 : ~model242412b94d4b\_efb77423d7adb44255913eac3d9377e8() { }

---

<div class="post-metadata">

**Author:** ![dr-jojo](https://avatars.discourse-cdn.com/v4/letter/d/f08c70/32.png) [@dr-jojo](https://discourse.mc-stan.org/u/dr-jojo)\
**Post date:** [November 6, 2020, 3:09pm UTC](https://discourse.mc-stan.org/t/rstan-install-trouble/19078/18 "2020-11-06T15:09:45Z")

</div>

102 :  
103 :  
104 : void transform\_inits(const stan::io::var\_context& context\_\_,  
105 : std::vector& params\_i\_\_,  
106 : std::vector& params\_r\_\_,  
107 : std::ostream\* pstream\_\_) const {  
108 : typedef double local\_scalar\_t\_\_;  
109 : stan::io::writer writer\_\_(params\_r\_\_, params\_i\_\_);  
110 : size\_t pos\_\_;  
111 : (void) pos\_\_; // dummy call to supress warning  
112 : std::vector vals\_r\_\_;  
113 : std::vector vals\_i\_\_;  
114 :  
115 : current\_statement\_begin\_\_ = 1;  
116 : if (!(context\_\_.contains\_r(“y”)))  
117 : stan::lang::rethrow\_located(std::runtime\_error(std::string(“Variable y missing”)), current\_statement\_begin\_\_, prog\_reader\_\_());  
118 : vals\_r\_\_ = context\_\_.vals\_r(“y”);  
119 : pos\_\_ = 0U;  
120 : context\_\_.validate\_dims(“parameter initialization”, “y”, “double”, context\_\_.to\_vec());  
121 : double y(0);  
122 : y = vals\_r\_\_[pos\_\_++];  
123 : try {  
124 : writer\_\_.scalar\_unconstrain(y);  
125 : } catch (const std::exception& e) {  
126 : stan::lang::rethrow\_located(std::runtime\_error(std::string("Error transforming variable y: “) + e.what()), current\_statement\_begin\_\_, prog\_reader\_\_());  
127 : }  
128 :  
129 : params\_r\_\_ = writer\_\_.data\_r();  
130 : params\_i\_\_ = writer\_\_.data\_i();  
131 : }  
132 :  
133 : void transform\_inits(const stan::io::var\_context& context,  
134 : Eigen::Matrix\<double, Eigen::Dynamic, 1\>& params\_r,  
135 : std::ostream\* pstream\_\_) const {  
136 : std::vector params\_r\_vec;  
137 : std::vector params\_i\_vec;  
138 : transform\_inits(context, params\_i\_vec, params\_r\_vec, pstream\_\_);  
139 : params\_r.resize(params\_r\_vec.size());  
140 : for (int i = 0; i \< params\_r.size(); ++i)  
141 : params\_r(i) = params\_r\_vec[i];  
142 : }  
143 :  
144 :  
145 : template \<bool propto\_\_, bool jacobian\_\_, typename T\_\_\>  
146 : T\_\_ log\_prob(std::vector\<T\_\_\>& params\_r\_\_,  
147 : std::vector& params\_i\_\_,  
148 : std::ostream\* pstream\_\_ = 0) const {  
149 :  
150 : typedef T\_\_ local\_scalar\_t\_\_;  
151 :  
152 : local\_scalar\_t\_\_ DUMMY\_VAR\_\_(std::numeric\_limits::quiet\_NaN());  
153 : (void) DUMMY\_VAR\_\_; // dummy to suppress unused var warning  
154 :  
155 : T\_\_ lp\_\_(0.0);  
156 : stan::math::accumulator\<T\_\_\> lp\_accum\_\_;  
157 : try {  
158 : stan::io::reader\<local\_scalar\_t\_\_\> in\_\_(params\_r\_\_, params\_i\_\_);  
159 :  
160 : // model parameters  
161 : current\_statement\_begin\_\_ = 1;  
162 : local\_scalar\_t\_\_ y;  
163 : (void) y; // dummy to suppress unused var warning  
164 : if (jacobian\_\_)  
165 : y = in\_\_.scalar\_constrain(lp\_\_);  
166 : else  
167 : y = in\_\_.scalar\_constrain();  
168 :  
169 : // model body  
170 :  
171 : current\_statement\_begin\_\_ = 1;  
172 : lp\_accum\_\_.add(normal\_log\<propto\_\_\>(y, y\_mean, 1));  
173 :  
174 : } catch (const std::exception& e) {  
175 : stan::lang::rethrow\_located(e, current\_statement\_begin\_\_, prog\_reader\_\_());  
176 : // Next line prevents compiler griping about no return  
177 : throw std::runtime\_error(”\*\*\* IF YOU SEE THIS, PLEASE REPORT A BUG _");  
178 : }  
179 :  
180 : lp\_accum\_\_.add(lp\_\_);  
181 : return lp\_accum\_\_.sum();  
182 :  
183 : } // log\_prob()  
184 :  
185 : template \<bool propto, bool jacobian, typename T\_\>  
186 : T\_ log\_prob(Eigen::Matrix\<T\_,Eigen::Dynamic,1\>& params\_r,  
187 : std::ostream pstream = 0) const {  
188 : std::vector\<T\_\> vec\_params\_r;  
189 : vec\_params\_r.reserve(params\_r.size());  
190 : for (int i = 0; i \< params\_r.size(); ++i)  
191 : vec\_params\_r.push\_back(params\_r(i));  
192 : std::vector vec\_params\_i;  
193 : return log\_prob\<propto,jacobian,T\_\>(vec\_params\_r, vec\_params\_i, pstream);  
194 : }  
195 :  
196 :  
197 : void get\_param\_names(std::vectorstd::string& names\_\_) const {  
198 : names\_\_.resize(0);  
199 : names\_\_.push\_back(“y”);  
200 : }  
201 :  
202 :  
203 : void get\_dims(std::vector\<std::vector\<size\_t\> \>& dimss\_\_) const {  
204 : dimss\_\_.resize(0);  
205 : std::vector\<size\_t\> dims\_\_;  
206 : dims\_\_.resize(0);  
207 : dimss\_\_.push\_back(dims\_\_);  
208 : }  
209 :  
210 : template   
211 : void write\_array(RNG& base\_rng\_\_,  
212 : std::vector& params\_r\_\_,  
213 : std::vector& params\_i\_\_,  
214 : std::vector& vars\_\_,  
215 : bool include\_tparams\_\_ = true,  
216 : bool include\_gqs\_\_ = true,  
217 : std::ostream pstream\_\_ = 0) const {  
218 : typedef double local\_scalar\_t\_\_;  
219 :  
220 : vars\_\_.resize(0);  
221 : stan::io::reader\<local\_scalar\_t\_\_\> in\_\_(params\_r\_\_, params\_i\_\_);  
222 : static const char_ function\_\_ = “model242412b94d4b\_efb77423d7adb44255913eac3d9377e8\_namespace::write\_array”;

---

<div class="post-metadata">

**Author:** ![dr-jojo](https://avatars.discourse-cdn.com/v4/letter/d/f08c70/32.png) [@dr-jojo](https://discourse.mc-stan.org/u/dr-jojo)\
**Post date:** [November 6, 2020, 3:10pm UTC](https://discourse.mc-stan.org/t/rstan-install-trouble/19078/19 "2020-11-06T15:10:26Z")

</div>

223 : (void) function\_\_; // dummy to suppress unused var warning  
224 :  
225 : // read-transform, write parameters  
226 : double y = in\_\_.scalar\_constrain();  
227 : vars\_\_.push\_back(y);  
228 :  
229 : double lp\_\_ = 0.0;  
230 : (void) lp\_\_; // dummy to suppress unused var warning  
231 : stan::math::accumulator lp\_accum\_\_;  
232 :  
233 : local\_scalar\_t\_\_ DUMMY\_VAR\_\_(std::numeric\_limits::quiet\_NaN());  
234 : (void) DUMMY\_VAR\_\_; // suppress unused var warning  
235 :  
236 : if (!include\_tparams\_\_ && !include\_gqs\_\_) return;  
237 :  
238 : try {  
239 : if (!include\_gqs\_\_ && !include\_tparams\_\_) return;  
240 : if (!include\_gqs\_\_) return;  
241 : } catch (const std::exception& e) {  
242 : stan::lang::rethrow\_located(e, current\_statement\_begin\_\_, prog\_reader\_\_());  
243 : // Next line prevents compiler griping about no return  
244 : throw std::runtime\_error("\*\*\* IF YOU SEE THIS, PLEASE REPORT A BUG \*\*\*");  
245 : }  
246 : }

---

<div class="post-metadata">

**Author:** ![dr-jojo](https://avatars.discourse-cdn.com/v4/letter/d/f08c70/32.png) [@dr-jojo](https://discourse.mc-stan.org/u/dr-jojo)\
**Post date:** [November 6, 2020, 3:11pm UTC](https://discourse.mc-stan.org/t/rstan-install-trouble/19078/20 "2020-11-06T15:11:00Z")

</div>

247 :  
248 : template   
249 : void write\_array(RNG& base\_rng,  
250 : Eigen::Matrix\<double,Eigen::Dynamic,1\>& params\_r,  
251 : Eigen::Matrix\<double,Eigen::Dynamic,1\>& vars,  
252 : bool include\_tparams = true,  
253 : bool include\_gqs = true,  
254 : std::ostream\* pstream = 0) const {  
255 : std::vector params\_r\_vec(params\_r.size());  
256 : for (int i = 0; i \< params\_r.size(); ++i)  
257 : params\_r\_vec[i] = params\_r(i);  
258 : std::vector vars\_vec;  
259 : std::vector params\_i\_vec;  
260 : write\_array(base\_rng, params\_r\_vec, params\_i\_vec, vars\_vec, include\_tparams, include\_gqs, pstream);  
261 : vars.resize(vars\_vec.size());  
262 : for (int i = 0; i \< vars.size(); ++i)  
263 : vars(i) = vars\_vec[i];  
264 : }  
265 :  
266 : std::string model\_name() const {  
267 : return “model242412b94d4b\_efb77423d7adb44255913eac3d9377e8”;  
268 : }  
269 :  
270 :  
271 : void constrained\_param\_names(std::vectorstd::string& param\_names\_\_,  
272 : bool include\_tparams\_\_ = true,  
273 : bool include\_gqs\_\_ = true) const {  
274 : std::stringstream param\_name\_stream\_\_;  
275 : param\_name\_stream\_\_.str(std::string());  
276 : param\_name\_stream\_\_ \<\< “y”;  
277 : param\_names\_\_.push\_back(param\_name\_stream\_\_.str());  
278 :  
279 : if (!include\_gqs\_\_ && !include\_tparams\_\_) return;  
280 :  
281 : if (include\_tparams\_\_) {  
282 : }  
283 :  
284 : if (!include\_gqs\_\_) return;  
285 : }  
286 :  
287 :  
288 : void unconstrained\_param\_names(std::vectorstd::string& param\_names\_\_,  
289 : bool include\_tparams\_\_ = true,  
290 : bool include\_gqs\_\_ = true) const {  
291 : std::stringstream param\_name\_stream\_\_;  
292 : param\_name\_stream\_\_.str(std::string());  
293 : param\_name\_stream\_\_ \<\< “y”;  
294 : param\_names\_\_.push\_back(param\_name\_stream\_\_.str());  
295 :  
296 : if (!include\_gqs\_\_ && !include\_tparams\_\_) return;  
297 :  
298 : if (include\_tparams\_\_) {  
299 : }  
300 :  
301 : if (!include\_gqs\_\_) return;  
302 : }  
303 :  
304 : }; // model  
305 :  
306 : } // namespace  
307 :  
308 : typedef model242412b94d4b\_efb77423d7adb44255913eac3d9377e8\_namespace::model242412b94d4b\_efb77423d7adb44255913eac3d9377e8 stan\_model;  
309 :  
310 : #ifndef USING\_R  
311 :  
312 : stan::model::model\_base& new\_model(  
313 : stan::io::var\_context& data\_context,  
314 : unsigned int seed,  
315 : std::ostream\* msg\_stream) {  
316 : stan\_model\* m = new stan\_model(data\_context, seed, msg\_stream);  
317 : return \*m;  
318 : }  
319 :  
320 : #endif  
321 :  
322 :  
323 :  
324 : #include \<rstan\_next/stan\_fit.hpp\>  
325 :  
326 : struct stan\_model\_holder {  
327 : stan\_model\_holder(rstan::io::rlist\_ref\_var\_context rcontext,  
328 : unsigned int random\_seed)  
329 : : rcontext\_(rcontext), random\_seed\_(random\_seed)

fi

[Next page](https://discourse.mc-stan.org/t/rstan-install-trouble/19078.md?page=2)
