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 “https://apps.dtic.mil/sti/pdfs/AD1076799.pdf” as my “ben_files.stan” file. Thank you very much.

# rstan

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 = f.read()

data_list = {‘n’: n, ‘p’: M, ‘c’: N, ‘k’: r}

posterior = stan.build(ben, data=data_list)

fit=posterior.fixed_param()

X=np.array(fit[‘X’][:,:,1000])

Y=np.array(fit[‘Y’][:,:,1000])