pystan or rstan

71 views
Skip to first unread message

Eugene Quinn

unread,
Jan 12, 2017, 8:50:36 AM1/12/17
to Stan users mailing list
I'm about to begin the third iteration of my Statistics for Science course using STAN, and I was wondering about using Jupyter/pystan instead of, or in conjunction with  R/Rsudio/rstan. 

This class is about 50% cs majors who aren't really interested in learning R, but need to learn Python.  The rest of the class is mostly environmental science and biology, and I think they would benefit from an introduction to Python as well.  

My main concern is getting the software to work in a diverse hardware/OS environment.  Maybe 60-65% of the students have macs, but the others have windows.

Any suggestions are most welcome.

Gene Quinn
Mathematics Department
Stonehill College

Ben Goodrich

unread,
Jan 12, 2017, 9:33:31 AM1/12/17
to Stan users mailing list

If you have a few hundred dollars or your students have a few dollars, I would suggest doing a course like that through Sage Math Cloud

https://cloud.sagemath.com/help#

They have rstan already but would pip install pystan for you. I would use it for my own class but the students are more comfortable with RStudio than Jupyter.

Ben

Bob Carpenter

unread,
Jan 12, 2017, 2:56:07 PM1/12/17
to stan-...@googlegroups.com
I'm surprised we don't get this question a lot, but I guess people
usually choose their language first, then look for packages in it.

PyStan and RStan Both call the same basic C++ code in Stan to do inference.

The ecosystem around RStan is much larger than around PyStan (packages like
ShinyStan, loo, RStanArm, and BayesPlot), but we'd love to have
some people train people in PyStan who could help close the gap!

You can see a basic Jupyter tutorial in Python
that Chris Fonnesbeck put together here:

http://mc-stan.org/documentation/case-studies/radon.html

So you can see that you get all the basic sampling and plotting
you need directly in PyStan (and other Python packages).

- Bob

P.S. "Stan" isn't an acronym, so we prefer "Stan" to "STAN". It's named
after Stanislaw Ulam.
> --
> 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.
> To post to this group, send email to stan-...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Emmanuel Charpentier

unread,
Jan 13, 2017, 6:07:30 AM1/13/17
to Stan users mailing list


Le jeudi 12 janvier 2017 15:33:31 UTC+1, Ben Goodrich a écrit :
On Thursday, January 12, 2017 at 8:50:36 AM UTC-5, Eugene Quinn wrote:
I'm about to begin the third iteration of my Statistics for Science course using STAN, and I was wondering about using Jupyter/pystan instead of, or in conjunction with  R/Rsudio/rstan. 

This class is about 50% cs majors who aren't really interested in learning R, but need to learn Python.  The rest of the class is mostly environmental science and biology, and I think they would benefit from an introduction to Python as well.  

Indeed. But as a mid- to long-term investment rather than a short-term commodity acquisition (see below)...

My main concern is getting the software to work in a diverse hardware/OS environment.  Maybe 60-65% of the students have macs, but the others have windows.

Any suggestions are most welcome.

If you have a few hundred dollars or your students have a few dollars, I would suggest doing a course like that through Sage Math Cloud

https://cloud.sagemath.com/help#

Nice idea. But a few caveats :

1) Sage is Python2-based ; this will change over time, but is a large task (in good way, but not yet here). This might be an hindrance if your students have been introduced to Python3 only, as it is likely nowadays.

On the other hand, introducing CS students to the necessities (and difficulties) of maintaining backward compatibility might be a Good Thing For Them(TM)...

2) Sage's R version is 3.2.4 ; it's in the process of being updated, but R's new dependance on an external SSL library opened a few cans of worms (mostly pseudo-legal concerns about what amounts in practice to a dependance on OpenSSL, which ruffles a few feathers...). The recent OpenSSL 1.1 tragicomedy has complicated things again (make that a crate of canned worms...), making upgrading Python the #1 priority (this done as of yesterday).

This should change soon (not as soon as I wished), but don't hold your breath : I'm on it since the end of last spring...

3) For practical purposes, R is (currently) vastly more useful to a biostatistician, a biologist, an ecologist or a physician than Python : almost 10 000 R packages have been developed over time, that cover an awful lot of applied statistical practice (and folklore (and prehistory)) ; this has also given R a reputation among journal reviewers, who aren't so keen to dispute an R package  worthiness as to scrutinize (suspiciously) a home-cooked Python program.

Bob (below) notes that the existence of (a lot of) Stan support R packages is a point to consider. He's right...

This also may change over time, given what is thought of as the "cleanliness" of Python over the "scruffy" nature of R (which is really Scheme with another syntax), which makes mastering it more an art than a science. But, again, it is not there yet.


They have rstan already but would pip install pystan for you. I would use it for my own class but the students are more comfortable with RStudio than Jupyter.

I found cloud.sagemath.com's staff extremely helpful and eager to help even users of "freebee" accounts. Installing pystan should be no problem (as long as your account has Internet access...). Ditto for rstan and its support packages.

Introducing various interfaces to your students should also be a Good Thing For Them(TM). Consider also R's interface to Jupyter (a. k. a. IRkernel), and maybe emacs+(markdown|LaTeX) (irreplaceable for serious work, such as publication...).

cloud.sagemath.com also offers a LaTeX editor claiming to have collaboration features, such as incremental compilation. I have no idea of its valu, being an emacs die-hard...

HTH,

--
Emmanuel Charpentier


Ben

Reply all
Reply to author
Forward
0 new messages