Rstan: naming, system, etc.

8 views
Skip to first unread message

Bob Carpenter

unread,
Feb 28, 2012, 3:49:40 PM2/28/12
to stan...@googlegroups.com
1. Naming

I'm with Andrew that we should call the package:

Stan

Though I like caps.

That confuses the code organization a bit now, as
we have a directory:

stan/rstan/rstan

with all of the R stuff in it. How about changing
the name of that to:

stan/R/stan

?

2. I'm looking at the stan.R code that Ben inserted.
It uses a system() call. Is this going to work cross
platform? That's where I was imagining we'd have a
compile command implemented through Rcpp so that the
compiler ran in the same process as R itself.

If we do a system call, we need to worry about supplying
an executable or having users compile the code.

Given our problems with Windows compilers, this may turn
out to be easier than compiling through R(cpp).

I don't understand the design decisions well enough here.


3. Is inline related to Rcpp in any way other than having
the same author? I did find this blog of John Cook's:

http://www.johndcook.com/blog/2011/06/30/calling-cpp-from-r/

- Bob

Ben Goodrich

unread,
Feb 28, 2012, 5:29:55 PM2/28/12
to stan development mailing list
On Feb 28, 3:49 pm, Bob Carpenter <c...@alias-i.com> wrote:
> 1.  Naming
>
> I'm with Andrew that we should call the package:
>
>     Stan
>
> Though I like caps.
>
> That confuses the code organization a bit now, as
> we have a directory:
>
>     stan/rstan/rstan
>
> with all of the R stuff in it.  How about changing
> the name of that to:
>
>     stan/R/stan
>
> ?

That is okay, although has the confusion that a directory will be stan/
R/stan/R/ .

But I am not sure we should change the name of the R package to stan.
The dominant naming convention for R packages that interface with
external software is to have R or R2 or something in the name
(R2WinBUGS, RcppEigen, etc.). If you ever intend to have them packaged
for Linux distributions, having two source packages with the same name
will cause some headaches. Finally, since stan the library is BSD and
stan the R package is GPL, I'd say that having distinct names would be
less legally confusing.

> 2.  I'm looking at the stan.R code that Ben inserted.
> It uses a system() call.  Is this going to work cross
> platform?  That's where I was imagining we'd have a
> compile command implemented through Rcpp so that the
> compiler ran in the same process as R itself.

Yes. Nowdays there is system2() which is more portable in a sense but
was only introduced into R a couple of years ago.

> If we do a system call, we need to worry about supplying
> an executable or having users compile the code.

Executable what exactly? Executables like demo/gm should exist once
the user installs the R package (whether they build it from source or
install the binary R package). For executables like particular models,
then the user would have to compile them, in which case on Windows
they need the Rtools toolchain (not VisualStudio).

> 3.  Is inline related to Rcpp in any way other than having
> the same author?  I did find this blog of John Cook's:

Most of the code in the inline package was originally written by Oleg
Sklyar. The inline package is a suggestency of the Rcpp package
because some R functions in Rcpp utilize inline.

Ben

Andrew Gelman

unread,
Feb 28, 2012, 5:57:47 PM2/28/12
to stan...@googlegroups.com
I would prefer the name to be "stan" not "Stan" but maybe Ben is right about namespace confusion? We could have stan be the C++ library and rstan be the R package? We can discuss more tomorrow...!

Bob Carpenter

unread,
Feb 28, 2012, 8:16:51 PM2/28/12
to stan...@googlegroups.com
On 2/28/12 5:29 PM, Ben Goodrich wrote:
> On Feb 28, 3:49 pm, Bob Carpenter<c...@alias-i.com> wrote:
>> 1. Naming
>>
>> I'm with Andrew that we should call the package:
>>
>> Stan
>>
>> Though I like caps.

> That is okay, although has the confusion that a directory will be stan/
> R/stan/R/ .

I was confused already by stan/rstan/rstan, but I don't know
the R conventions for laying out code.

> But I am not sure we should change the name of the R package to stan.
> The dominant naming convention for R packages that interface with
> external software is to have R or R2 or something in the name
> (R2WinBUGS, RcppEigen, etc.).

You'll have to take that one up with andrew. I only know
R2WinBugs and R2jags and Rcpp, but Andrew thought having the
R was tacky.

> If you ever intend to have them packaged
> for Linux distributions, having two source packages with the same name
> will cause some headaches. Finally, since stan the library is BSD and
> stan the R package is GPL, I'd say that having distinct names would be
> less legally confusing.

(R)?2(S|s)tan the R package will be BSD-ed, too.
Only the *combination* of R2stan and R become
GPL-ed. That'll let us host on Google Code (which
doesn't or at least didn't allow GPL code hosting),
and also let people distribute all of (R)stan without
worrying about the GPL (unless they link to R and
redistribute).

>> 2. I'm looking at the stan.R code that Ben inserted.
>> It uses a system() call. Is this going to work cross
>> platform? That's where I was imagining we'd have a
>> compile command implemented through Rcpp so that the
>> compiler ran in the same process as R itself.
>
> Yes. Nowdays there is system2() which is more portable in a sense but
> was only introduced into R a couple of years ago.
>
>> If we do a system call, we need to worry about supplying
>> an executable or having users compile the code.
>
> Executable what exactly? Executables like demo/gm should exist once
> the user installs the R package (whether they build it from source or
> install the binary R package). For executables like particular models,
> then the user would have to compile them, in which case on Windows
> they need the Rtools toolchain (not VisualStudio).

I'm clearly very confused about how all the pieces fit
together here and who's in charge of what and when things
get compiled. The doc so far hasn't helped, but I haven't
read the 150+ page R extensions package manual.

- Bob

Ben Goodrich

unread,
Feb 28, 2012, 10:13:06 PM2/28/12
to stan...@googlegroups.com
OK, this would probably be easier if I just came to the stan meeting. When is that?

What I had in my head was that the R package would have an inst/include/ directory that basically contained stan/src/. When the R package gets installed (from source), the installation would essentially involve a "make demo/gm". That is essentially what the RcppEigen package does. The binary version of the R package (built from source by / on CRAN's servers) would thus have the demo/gm executable.

Once the R package is installed and loaded, the main stan() function would use the system() or system2() function to pass a .stan text file to demo/gm to yield the C++ file, which would then get processed by Rcpp's magic. Then, the main stan() function would use the .Call() function in R to pass the data to the just-compiled model and execute.

But there are probably other ways to do it as well.

Ben

Andrew Gelman

unread,
Feb 28, 2012, 10:24:03 PM2/28/12
to stan...@googlegroups.com
Stan mtg is at my stat dept ofc, usually Wednesdays from about 12-3, or 12-2, or 1-3, or whatever.  Tomorrow I should be getting there at 13.30.
See you
A

P.S.  I'd much prefer calling the R package stan rather than Stan.  I just think it's hard to keep track of capital letters....

Andrew Gelman

unread,
Feb 29, 2012, 1:00:55 PM2/29/12
to stan...@googlegroups.com
Hi all. I was wondering why nobody was here and I checked and saw what I had written. I have to _leave_ today at 13.30; I mistakenly wrote that I was arriving then. If anyone is around, maybe we could talk now? Otherwise you can all meet without me...
A
Reply all
Reply to author
Forward
0 new messages