From rstan to pystan 3 when permutation = TRUE and "Fixed_param" are present

I have been using stan in R, and now I’m trying to execute it using pystan 3. I’m not sure if the following code is correct. The output seems to differ significantly. However, I refer to Listing 2 in the document “” as my “ben_files.stan” file. Thank you very much.


n ← 100
M ← 3
N ← 4
H ← 3
r ← 3
data_list ← list(n=100, p=M, c=N, k=r)
fit ← stan(file = “ben_files.stan”, data = data_list, chain=1, algorithm=‘Fixed_param’)
fit_ss ← extract(fit, permuted = TRUE)
X ← fit_ss$X[1000, , ]
Y ← fit_ss$Y[1000, , ]

pystan 3

n = 100
M = 3
N = 4
H = 3
r = 3
f = open(‘ben_files.stan’, ‘r’)
ben =
data_list = {‘n’: n, ‘p’: M, ‘c’: N, ‘k’: r}
posterior =, data=data_list)

Results may vary if the underlying version of Stan is different.

If the versions are identical and you specify a random seed, you should be able to get identical draws. I don’t know about the ordering of the draws. That might be different.

You may also need to check that the number of warmup steps etc is identical.

Do you think that the codes are equivalent? That’s what I want to know.

Looks equivalent to me. I’m not an RStan user though.

I imagine checking would be easy: summary statistics of the draws should match.

I am writing books on Stan. The R version has been done. However,… The program for reduced rank regression by Ben Files does not work for Python and PyStan 3.