Any Comprehensive Tutorial on the new Syntax in PyStan3?

Hi guys,

I recently switched from Rstan to PyStan, and I tried PyStan3. I didn’t get why we have to change the syntax, since in R I can use the old syntax even with the latest Stan. So I guess it’s an issue with PyStan3, not with Stan, which can still process flexibly several syntaxes. So, any sources with a complete syntax changes for PyStan3

I have just been noticing the following ones:

I cannot write:

vector[k] y[n];

to indicate a vector-of-vector structure, and actually I can’t specify dimension after variable declaration, so it only accepts:

vector[k] y;

and I have to work with matrices in case I wanted vector-of-vector:

matrix[k, n] y;

and be careful when using a row of the matrix as a vector because often some operations require a vector, but if you pick a row from the matrix you have a row_vector, so you have to do

for (i in 1:k) {
    target += log_softmax(to_vector(y[i]);
}

These are just very trivial examples, but other things changed a lot in PyStan3. Any plan to have a repository of syntax changes for several use cases?

The main change is the new array syntax in Stan, which is described here Removed Features.

Of note, this is not unique to PyStan. The reason you haven’t noticed it in rstan yet is just because rstan is behind the current Stan version.

3 Likes

oh man that’s actually everything I needed ahaha
Thanks a lot!

1 Like