Using RStan with knitr

1,691 views
Skip to first unread message

Jeffrey Arnold

unread,
Nov 27, 2014, 11:04:07 PM11/27/14
to stan-...@googlegroups.com

In some previous threads there’s been questions of how best to use Rstan in knitr documents. Generally people will write the Stan model as a string, and pass that string to the stan function using the model_code argument. However, another (and in my option, better) way to do this is to take advantage of language engines in knitr (http://yihui.name/knitr/demo/engines/). With these engines you can write a Stan code in a separate chunk and still use it later. There are a couple of ways of doing this

  1. Use the cat engine to write the chunk contents to a file, which you can use with stan or stan_model later.
  2. Use a custom stan engine which will compile the contents of the chunk to a stanmodel object which can be sampled with the sampling method.

For the details and an example of an rmarkdown document which uses these approaches see the example document in https://github.com/jrnold/knitr-stan-example .

Andrew Gelman

unread,
Nov 27, 2014, 11:39:47 PM11/27/14
to stan-...@googlegroups.com
People should not be using stan model as a string!  We should fix the Rstan documentation so that the string is not presented as the default option.

--
You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andrew Gelman

unread,
Nov 28, 2014, 10:50:51 AM11/28/14
to stan-...@googlegroups.com
Sorry—I see that the Rstan documentation has been fixed already.  So I think that eventually people will start following our instructions and reading in Stan programs from files.
A

Jeffrey Arnold

unread,
Nov 28, 2014, 11:56:20 AM11/28/14
to stan-...@googlegroups.com
Since it may have been unclear what I was saying, I was not suggesting that people write the Stan model in R strings, I was showing ways in which one can write Stan models within a knitr document in their own chunks.  Specifically, I wrote a Stan engine for knitr so (after defining the new engine) you can write a Stan model in a knitr chunk like this:
```{r engine='stan',engine.opts=list(x = "mod")}
parameters {
  real y[2]; 
} 
model {
  y[1] ~ normal(0, 1);
  y[2] ~ double_exponential(0, 2);
} 
```
Which will compile the Stan code, and save it to a stanmodel object named mod, which can be used in later chunks, e.g.
```{r}
mod <- sampling(mod) 
print(mod)
```
Another way is to write a chunk like this 
```{r engine='cat',engine.opts=list(file="foo.stan",lang="stan")}
parameters {
  real y[2]; 
} 
model {
  y[1] ~ normal(0, 1);
  y[2] ~ double_exponential(0, 2);
} 
```
This writes the model in a chunk to a file "foo.stan", which can be used later.
```{r}
stan("foo.stan") 
```
So, for those who want to (1) use knitr and (2) keep everything in the same document, those are a couple of ways to do it without writing Stan models in R strings.

-- 
Jeffrey Arnold
University of Washington
Acting Assistant Professor of Political Science
Core Faculty Member of the Center for Statistics and the Social Sciences

Bob Carpenter

unread,
Nov 28, 2014, 1:37:34 PM11/28/14
to stan-...@googlegroups.com
I've been playing around with knitr and found I could put the
Stan program in a standalone file with this bit of magic:

```{r, cache.extra = tools::md5sum("soil_incubation_measurement_err.stan")}
fit_me <- stan("soil_incubation_measurement_err.stan",
data=c("totalC_t0", "t0", "N_t", "ts", "eCO2mean", "eCO2sd"),
control=list(adapt_delta=0.90,
stepsize=0.005),
chains=4, iter=1000, seed=1234);
```

Here the model is in the same directory as the R markdown knitr doc, but you
could have it anywhere and use a relative path. The cache.extra command says to
use the contents of the file to determine whether to rerun the block.

At the very top of the document, I just gave everything make-like behavior
with this caching config:

```{r setup, include=FALSE}
knitr::opts_chunk$set(cache=TRUE)
```

which is a game changer in actually updating one of these docs that
happens to have a Stan program that takes 10 minutes to run.

I'll be breaking out my R code, too, once I figure out how to do it.
I really dislike having text and R code and Stan code jumbled into
a single long scrolling doc. Call me "illiterate." Just to be clear, I do
believe function specifications (i.e., API doc) and code comments should go
in the code. Everything else just gets in the way when coding.

Speaking of doc, the best I've found for knitr + R markdown is this:

http://rmarkdown.rstudio.com

The knitr doc itself, or least what I could find of it, left me very
confused. I think (but am still not 100% sure), that there are two different
and mostly incompatible ways of using knitr, one with R markdown and HTML to
produce HTML and one with I'm not sure what and LaTeX to produce LaTeX docs.
Others have told me to just use Sweave for LaTeX output. I was hoping I could
write once and publish in both HTML and PDF to make it easy for us to do things
like document example models. It's possible, but not all the R
markdown or HTML passes to LaTeX and vice versa, so I still don't know the rules
for making portable docs. The output's customizable, but has terrible styles
by default in both LaTeX and HTML (and I didn't see any reasonable HTML styles,
so if I keep using this, it's back to CSS for styling --- at least it generates
HTML [though I haven't looked at the generated HTML to see what I'd need to style]).

There's also a book on knitr by its author, Yihui Xie. The
kindle version looks well converted judging by the sample (CRC seems
to have gotten their act together), but in addition to being $45, it's
already over a year old.

- Bob

Sean O'Riordain

unread,
Nov 28, 2014, 2:00:39 PM11/28/14
to stan-...@googlegroups.com
Bob,
Using a very recent release of RStudio -  0.98.1091, I have just created a sample RMarkdown file from the template and I chose output type of PDF and saved it as test.Rmd.  At the top of the file it says:

---
title: "test"
author: "Seán Ó Ríordáin"
date: "11/28/2014"
output: pdf_document
---
blah blah blah...

Above this there is a button which says "Knit PDF"... and it does knit to a nice pdf if I press the button.

If I change the above line to
output: html_document
the button changes to "Knit HTML"... and on pressing the button it knits to HTML

I don't know what the knitr commands under the hood do this though - I haven't looked :-).

Hope that helps,
Seán

Kind regards,

Sean O'Riordain


Sean O'Riordain

unread,
Nov 28, 2014, 2:01:45 PM11/28/14
to stan-...@googlegroups.com
Meant to say that I found the Knitr book useful.

Jeffrey Arnold

unread,
Nov 28, 2014, 2:37:24 PM11/28/14
to stan-...@googlegroups.com
I prefer having separate files, and use Make or other build tools to build everything. But that's not the only way people use it, especially for quick one-off analyses, so I was just offering some alternatives for those who want everything in a single document.  Especially since knitr and other tools like it are widespread in scientific computing and only growing in usage, I just thought it important to make it as easy as possible to use Stan within them.

With the Stan model in a separate file, the other chunk that's useful to add is one to display the model code: 

```{r results='markup',echo=FALSE,comment=""}
cat(paste(readLines("foo.stan"), collapse = "\n"))
```

Here's the best way to keep your R code in a separate file while using knitr: http://yihui.name/knitr/demo/externalization/

Another option is to work backwards from an R file with comments using the spin function: http://yihui.name/knitr/demo/stitch/

Knitr is a general report generating environment. So can mix chunks of R (or other programming languages) with a variety of markup languages (actually any markup language, since it is customizable). Markdown and LaTeX are the most common, but you can also use knitr with html, reStructuredText, asciidoc and others.  A bunch of examples of knitr using different markup languages are here: http://yihui.name/knitr/demo/minimal/.  So if you really hate writing markdown, you can use knitr with html: https://github.com/yihui/knitr-examples/blob/master/003-minimal.Rhtml.   But, I think that writing it in markdown is the way to go to produce html & pdf.  But the key is good templates, and separating content from presentation. In my workflow, I use make and knitr for Rmd -> md, and then pandoc to convert the markdown file to either or both html and pdf. I don't rely on the default pandoc templates, but write my own.  Rstudio and the package rmarkdown seem to use their own version of templates which seem to be based on pandoc templates since that's what its using in the background  http://rmarkdown.rstudio.com/developer_document_templates.html.

In any case, I have an open pull request to add a Stan engine to knitr https://github.com/yihui/knitr/pull/903 ,  so maybe future versions of knitr will include a Stan engine.


-- 
Jeffrey Arnold
University of Washington
Acting Assistant Professor of Political Science
Core Faculty Member of the Center for Statistics and the Social Sciences


Bill Harris

unread,
Nov 29, 2014, 10:46:38 AM11/29/14
to stan-...@googlegroups.com
Bob Carpenter <ca...@alias-i.com> writes:

> I'll be breaking out my R code, too, once I figure out how to do it.
> I really dislike having text and R code and Stan code jumbled into
> a single long scrolling doc. Call me "illiterate." Just to be clear, I do
> believe function specifications (i.e., API doc) and code comments should go
> in the code. Everything else just gets in the way when coding.

Just curious: how do people find RStudio with knitr compared to Emacs,
ESS, and org mode?

I've used the latter for a long time, and I find it powerful and
flexible. It seems to be able to do most if not all of what the former
can do, and it provides a familiar environment that carries across
tasks.

The only two things I sometimes regret are that org mode is so flexible
that I sometimes find I've misconfigured a code block through some file
setting that I have to find and that the CSS it uses to produce an ODT
file seems to need some prettying (and I'm not a CSS expert).

I started trying RStudio last week, and there's much to like--indeed, it
seems to have many of the same features as org mode--but it seems to be
getting the flexibility that can lead to the complexity challenges I
sometimes find in org mode (witness Bob's chunk options example).

Bill
--
Bill Harris
Facilitated Systems
http://makingsense.facilitatedsystems.com/

Avraham Adler

unread,
Dec 2, 2014, 6:15:07 PM12/2/14
to stan-...@googlegroups.com, jrn...@uw.edu
What I've done is keep the stan files seperate (much cleaner that way),  read in the stan file in a knitr chunk when running, and have used lstinputlisting to display the stan file. This was with older versions of RStudio, though.

Bill Harris

unread,
Jan 2, 2015, 3:24:50 PM1/2/15
to stan-...@googlegroups.com
Now that I've touted org-mode's (and ESS's) capabilities, I realized I've not tried it with Stan on Windows.  When I did, I get errors, no matter the model.

To make it concrete, here's the result of trying to compile the model at https://github.com/stan-dev/example-models/blob/master/ARM/Ch.4/earn_height.stan with earn and height replaced by y and x.

In ESS (and presumably in org-mode, but I didn't diff the two to look for differences), I get these errors and no model:

> stanfitTEST <- stan(model_code = model_code, data=test_data, iter=100,chains=4)

TRANSLATING MODEL 'model_code' FROM Stan CODE TO C++ CODE NOW.
COMPILING THE C++ CODE FOR MODEL 'model_code' NOW.
In file included from c:/R/R-3.1.2/library/rstan/include//stansrc/stan/math/matrix_error_handling.hpp:17:0,
                 from c:/R/R-3.1.2/library/rstan/include//stansrc/stan/prob/transform.hpp:22,
                 from c:/R/R-3.1.2/library/rstan/include//stansrc/stan/io/reader.hpp:5,
                 from c:/R/R-3.1.2/library/rstan/include//stansrc/stan/model/model_header.hpp:24,
                 from filecb861b222ec.cpp:8:
c:/R/R-3.1.2/library/rstan/include//stansrc/stan/math/error_handling/matrix/check_pos_semidefinite.hpp: In function 'bool stan::math::check_pos_semidefinite(const char*, const Eigen::Matrix<LhsScalar, -1, -1, 0>&, const char*, T_result*)':
c:/R/R-3.1.2/library/rstan/include//stansrc/stan/math/error_handling/matrix/check_pos_semidefinite.hpp:41:71: warning: typedef 'size_type' locally defined but not used [-Wunused-local-typedefs]
       typedef typename index_type<Matrix<T_y,Dynamic,Dynamic> >::type size_type;
                                                                       ^
In file included from c:/R/R-3.1.2/library/rstan/include/rstan/rstaninc.hpp:3:0,
                 from filecb861b222ec.cpp:370:
c:/R/R-3.1.2/library/rstan/include/rstan/stan_fit.hpp: In instantiation of 'int rstan::{anonymous}::sampler_command(rstan::stan_args&, Model&, Rcpp::List&, const std::vector<long unsigned int>&, const std::vector<std::basic_string<char> >&, RNG_t&) [with Model = modelcb83d5313a6_model_code_namespace::modelcb83d5313a6_model_code; RNG_t = boost::random::additive_combine_engine<boost::random::linear_congruential_engine<unsigned int, 40014u, 0u, 2147483563u>, boost::random::linear_congruential_engine<unsigned int, 40692u, 0u, 2147483399u> >; Rcpp::List = Rcpp::Vector<19>]':
c:/R/R-3.1.2/library/rstan/include/rstan/stan_fit.hpp:1312:49:   required from 'SEXPREC* rstan::stan_fit<Model, RNG_t>::call_sampler(SEXP) [with Model = modelcb83d5313a6_model_code_namespace::modelcb83d5313a6_model_code; RNG_t = boost::random::additive_combine_engine<boost::random::linear_congruential_engine<unsigned int, 40014u, 0u, 2147483563u>, boost::random::linear_congruential_engine<unsigned int, 40692u, 0u, 2147483399u> >; SEXP = SEXPREC*]'
filecb861b222ec.cpp:381:126:   required from here
c:/R/R-3.1.2/library/rstan/include/rstan/stan_fit.hpp:732:15: warning: unused variable 'return_code' [-Wunused-variable]
           int return_code = stan::common::do_bfgs_optimize(model, lbfgs, base_rng,
               ^
c:/R/R-3.1.2/library/rstan/include/rstan/stan_fit.hpp:796:15: warning: unused variable 'return_code' [-Wunused-variable]
           int return_code = stan::common::do_bfgs_optimize(model, bfgs, base_rng,
               ^
c:/R/R-3.1.2/library/rstan/include/rstan/stan_fit.hpp:616:14: warning: unused variable 'init_log_prob' [-Wunused-variable]
       double init_log_prob;
              ^
c:/R/R-3.1.2/library/rstan/libstan/x64/libstan.a(agrad__rev__var_stack.o):agrad__rev__var_stack.cpp:(.data$_ZTISt9bad_alloc[_ZTISt9bad_alloc]+0x0): multiple definition of `typeinfo for std::bad_alloc'
filecb861b222ec.o:filecb861b222ec.cpp:(.rdata$_ZTISt9bad_alloc[_ZTISt9bad_alloc]+0x0): first defined here
c:/R/R-3.1.2/library/rstan/libstan/x64/libstan.a(agrad__rev__var_stack.o):agrad__rev__var_stack.cpp:(.data$_ZTISt9exception[_ZTISt9exception]+0x0): multiple definition of `typeinfo for std::exception'
filecb861b222ec.o:filecb861b222ec.cpp:(.rdata$_ZTISt9exception[_ZTISt9exception]+0x0): first defined here
c:/R/R-3.1.2/library/rstan/libstan/x64/libstan.a(agrad__rev__var_stack.o):agrad__rev__var_stack.cpp:(.text.startup+0xb): undefined reference to `__gxx_personality_sj0'
c:/R/R-3.1.2/library/rstan/libstan/x64/libstan.a(agrad__rev__var_stack.o):agrad__rev__var_stack.cpp:(.text.startup+0xb): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__gxx_personality_sj0'
c:/R/R-3.1.2/library/rstan/libstan/x64/libstan.a(agrad__rev__var_stack.o):agrad__rev__var_stack.cpp:(.text.startup+0x47): undefined reference to `_Unwind_SjLj_Register'
c:/R/R-3.1.2/library/rstan/libstan/x64/libstan.a(agrad__rev__var_stack.o):agrad__rev__var_stack.cpp:(.text.startup+0x47): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `_Unwind_SjLj_Register'
c:/R/R-3.1.2/library/rstan/libstan/x64/libstan.a(agrad__rev__var_stack.o):agrad__rev__var_stack.cpp:(.text.startup+0x10b): undefined reference to `operator new(unsigned long long)'
c:/R/R-3.1.2/library/rstan/libstan/x64/libstan.a(agrad__rev__var_stack.o):agrad__rev__var_stack.cpp:(.text.startup+0x10b): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `operator new(unsigned long long)'
c:/R/R-3.1.2/library/rstan/libstan/x64/libstan.a(agrad__rev__var_stack.o):agrad__rev__var_stack.cpp:(.text.startup+0x166): undefined reference to `operator new(unsigned long long)'
c:/R/R-3.1.2/library/rstan/libstan/x64/libstan.a(agrad__rev__var_stack.o):agrad__rev__var_stack.cpp:(.text.startup+0x166): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `operator new(unsigned long long)'
c:/R/R-3.1.2/library/rstan/libstan/x64/libstan.a(agrad__rev__var_stack.o):agrad__rev__var_stack.cpp:(.text.startup+0x2bd): undefined reference to `_Unwind_SjLj_Unregister'
c:/R/R-3.1.2/library/rstan/libstan/x64/libstan.a(agrad__rev__var_stack.o):agrad__rev__var_stack.cpp:(.text.startup+0x2bd): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `_Unwind_SjLj_Unregister'
c:/R/R-3.1.2/library/rstan/libstan/x64/libstan.a(agrad__rev__var_stack.o):agrad__rev__var_stack.cpp:(.text.startup+0x38e): undefined reference to `_Unwind_SjLj_Resume'
c:/R/R-3.1.2/library/rstan/libstan/x64/libstan.a(agrad__rev__var_stack.o):agrad__rev__var_stack.cpp:(.text.startup+0x38e): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `_Unwind_SjLj_Resume'
collect2: error: ld returned 1 exit status

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


     <program source elided>

Error in compileCode(f, code, language = language, verbose = verbose) :
  Compilation ERROR, function(s)/method(s) not created! In file included from c:/R/R-3.1.2/library/rstan/include//stansrc/stan/math/matrix_error_handling.hpp:17:0,
                 from c:/R/R-3.1.2/library/rstan/include//stansrc/stan/prob/transform.hpp:22,
                 from c:/R/R-3.1.2/library/rstan/include//stansrc/stan/io/reader.hpp:5,
                 from c:/R/R-3.1.2/library/rstan/include//stansrc/stan/model/model_header.hpp:24,
                 from filecb861b222ec.cpp:8:
c:/R/R-3.1.2/library/rstan/include//stansrc/stan/math/error_handling/matrix/check_pos_semidefinite.hpp: In function 'bool stan::math::check_pos_semidefinite(const char*, const Eigen::Matrix<LhsScalar, -1, -1, 0>&, const char*, T_result*)':
c:/R/R-3.1.2/library/rstan/include//stansrc/stan/math/error_handling/matrix/check_pos_semidefinite.hpp:41:71: warning: typedef 'size_type' locally defined but not used [-Wunused-local-typedefs]
       typedef typename index_type<Matrix<T_y,Dynamic,Dynamic> >::typ


In RStudio, I get

> stanfitTEST <- stan(model_code = model_code, data=test_data, iter=100,chains=4)

TRANSLATING MODEL 'model_code' FROM Stan CODE TO C++ CODE NOW.
COMPILING THE C++ CODE FOR MODEL 'model_code' NOW.
In file included from C:/R/R-3.1.2/library/rstan/include/rstan/rstaninc.hpp:3:0,
                 from file138473c31902.cpp:370:
C:/R/R-3.1.2/library/rstan/include/rstan/stan_fit.hpp: In function 'int rstan::{anonymous}::sampler_command(rstan::stan_args&, Model&, Rcpp::List&, const std::vector<long long unsigned int>&, const std::vector<std::basic_string<char> >&, RNG_t&) [with Model = model1384750d7b01_model_code_namespace::model1384750d7b01_model_code, RNG_t = boost::random::additive_combine_engine<boost::random::linear_congruential_engine<unsigned int, 40014u, 0u, 2147483563u>, boost::random::linear_congruential_engine<unsigned int, 40692u, 0u, 2147483399u> >, Rcpp::List = Rcpp::Vector<19>]':
C:/R/R-3.1.2/library/rstan/include/rstan/stan_fit.hpp:1311:7:   instantiated from 'SEXPREC* rstan::stan_fit<Model, RNG_t>::call_sampler(SEXP) [with Model = model1384750d7b01_model_code_namespace::model1384750d7b01_model_code, RNG_t = boost::random::additive_combine_engine<boost::random::linear_congruential_engine<unsigned int, 40014u, 0u, 2147483563u>, boost::random::linear_congruential_engine<unsigned int, 40692u, 0u, 2147483399u> >, SEXP = SEXPREC*]'
file138473c31902.cpp:381:128:   instantiated from here
C:/R/R-3.1.2/library/rstan/include/rstan/stan_fit.hpp:732:15: warning: unused variable 'return_code' [-Wunused-variable]
C:/R/R-3.1.2/library/rstan/include/rstan/stan_fit.hpp:1311:7:   instantiated from 'SEXPREC* rstan::stan_fit<Model, RNG_t>::call_sampler(SEXP) [with Model = model1384750d7b01_model_code_namespace::model1384750d7b01_model_code, RNG_t = boost::random::additive_combine_engine<boost::random::linear_congruential_engine<unsigned int, 40014u, 0u, 2147483563u>, boost::random::linear_congruential_engine<unsigned int, 40692u, 0u, 2147483399u> >, SEXP = SEXPREC*]'
file138473c31902.cpp:381:128:   instantiated from here
C:/R/R-3.1.2/library/rstan/include/rstan/stan_fit.hpp:796:15: warning: unused variable 'return_code' [-Wunused-variable]
C:/R/R-3.1.2/library/rstan/include/rstan/stan_fit.hpp:1311:7:   instantiated from 'SEXPREC* rstan::stan_fit<Model, RNG_t>::call_sampler(SEXP) [with Model = model1384750d7b01_model_code_namespace::model1384750d7b01_model_code, RNG_t = boost::random::additive_combine_engine<boost::random::linear_congruential_engine<unsigned int, 40014u, 0u, 2147483563u>, boost::random::linear_congruential_engine<unsigned int, 40692u, 0u, 2147483399u> >, SEXP = SEXPREC*]'
file138473c31902.cpp:381:128:   instantiated from here
C:/R/R-3.1.2/library/rstan/include/rstan/stan_fit.hpp:616:14: warning: unused variable 'init_log_prob' [-Wunused-variable]

SAMPLING FOR MODEL 'model_code' NOW (CHAIN 1).
.
.
.

Does this suggest anything in particular to look at?  I realize I may need to ask ESS or Rcpp folk, but I thought I'd check here first. 

Incidentally, I've been a relatively frequent user of ESS and org-mode with R for several years and not encountered such problems except with Stan.  I'm guessing it has to do with Rcpp somehow, but I don't (yet) know enough C++ to build simple test cases easily.

Thanks,

Bill

Jiqiang Guo

unread,
Jan 2, 2015, 10:57:13 PM1/2/15
to stan-...@googlegroups.com
I don't use Emacs, so I cannot help much.  

Does this emacs use the same c++ compiler that gets used when rstan is installed?  And we need to make sure rstan works on regular R on this particular machine first? 

Jiqiang 

--

ecb...@northshore.org

unread,
Jan 3, 2015, 11:53:55 AM1/3/15
to stan-...@googlegroups.com, gel...@stat.columbia.edu
What is the down-side to embedding a stan model specification in a string, vs. an external file?

Bill Harris

unread,
Jan 3, 2015, 7:57:50 PM1/3/15
to stan-...@googlegroups.com
Jiqiang Guo <guo...@gmail.com> writes:

> I don't use Emacs, so I cannot help much.
>
> Does this emacs use the same c++ compiler that gets used when rstan is
> installed? And we need to make sure rstan works on regular R on this
> particular machine first?

Jiqiang,

AFAIK, it does, but I'm not at that W7 machine now to check. I've got
cygwin and Rtools installed, and I think that I've got PATH set to pick
Rtools first.

Rstan does work on that W7 machine using RStudio. I can try to check on
Monday.

I just double-checked; Rstan seems to work fine inside org-mode version
8.2.1 on my Linux box.

Bob Carpenter

unread,
Jan 4, 2015, 4:21:29 PM1/4/15
to stan-...@googlegroups.com
For me, it's more about modularity. The model isn't part
of the R code --- the R code's a script to run the model.
I often run the same model over different data sets and
like to have a script per data set calling the same external
model.

I personally don't like embedding R scripts directly in knitr/sweave
docs for the same reason.

For those of us who want to debug using CmdStan (more direct),
we have to cut and paste out of the R string. And usually try
to figure out how to recreate a standalone data set.

I like the emacs mode for Stan, but that's only relevant
if you use emacs (we've had requests to do it as an embedded
mode in ESS).

There's no fundamental reason not to use it --- using a file
essentially just reads the model string out of the file and
passes it to our C++ translator.

- Bob

Bill Harris

unread,
Jan 5, 2015, 4:56:39 PM1/5/15
to stan-...@googlegroups.com
Good catch!

RStudio uses RBuildTools:

> system('g++ -v')
Using built-in specs.
COLLECT_GCC=C:\RBUILD~1\3.1\GCC-46~1.3\bin\G__~1.EXE
COLLECT_LTO_WRAPPER=c:/rbuild~1/3.1/gcc-46~1.3/bin/../libexec/gcc/i686-w64-mingw32/4.6.3/lto-wrapper.exe
Target: i686-w64-mingw32
Configured with: /data/gannet/ripley/Sources/mingw-test3/src/gcc/configure --host=i686-w64-mingw32 --build=x86_64-linux-gnu --target=i686-w64-mingw32 --with-sysroot=/data/gannet/ripley/Sources/mingw-test3/mingw32mingw32/mingw32 --prefix=/data/gannet/ripley/Sources/mingw-test3/mingw32mingw32/mingw32 --with-gmp=/data/gannet/ripley/Sources/mingw-test3/mingw32mingw32/prereq_install --with-mpfr=/data/gannet/ripley/Sources/mingw-test3/mingw32mingw32/prereq_install --with-mpc=/data/gannet/ripley/Sources/mingw-test3/mingw32mingw32/prereq_install --disable-shared --enable-static --enable-targets=all --enable-languages=c,c++,fortran --enable-libgomp --enable-sjlj-exceptions --enable-fully-dynamic-string --disable-nls --disable-werror --enable-checking=release --disable-win32-registry --disable-rpath --disable-werror CFLAGS='-O2 -mtune=core2 -fomit-frame-pointer' LDFLAGS=
Thread model: win32
gcc version 4.6.3 20111208 (prerelease) (GCC) 

Org-mode uses cygwin:

> system('g++ -v')
Using built-in specs.
COLLECT_GCC=/usr/bin/g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-cygwin/4.8.3/lto-wrapper.exe
Target: x86_64-pc-cygwin
Configured with: /cygdrive/i/szsz/tmpp/gcc_old/gcc-4.8.3-5.x86_64/src/gcc-4.8.3/configure --srcdir=/cygdrive/i/szsz/tmpp/gcc_old/gcc-4.8.3-5.x86_64/src/gcc-4.8.3 --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/libexec --datadir=/usr/share --localstatedir=/var --sysconfdir=/etc --libdir=/usr/lib --datarootdir=/usr/share --docdir=/usr/share/doc/gcc --htmldir=/usr/share/doc/gcc/html -C --build=x86_64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-pc-cygwin --without-libiconv-prefix --without-libintl-prefix --libexecdir=/usr/lib --enable-shared --enable-shared-libgcc --enable-static --enable-version-specific-runtime-libs --enable-bootstrap --enable-__cxa_atexit --with-dwarf2 --with-tune=generic --enable-languages=ada,c,c++,fortran,lto,objc,obj-c++ --enable-graphite --enable-threads=posix --enable-libatomic --enable-libgomp --disable-libitm --enable-libquadmath --enable-libquadmath-support --enable-libssp --enable-libada --enable-libgcj-sublibs --disable-java-awt --disable-symvers --with-ecj-jar=/usr/share/java/ecj.jar --with-gnu-ld --with-gnu-as --with-cloog-include=/usr/include/cloog-isl --without-libiconv-prefix --without-libintl-prefix --with-system-zlib --enable-linker-build-id
Thread model: posix
gcc version 4.8.3 (GCC)

Now I just need to figure out how to introduce ESS and org-mode to RBuildTools.

Bill
Reply all
Reply to author
Forward
0 new messages