A Matlab interface to Stan, a package for Bayesian inference.
For more information on Stan and its modeling language, see the Stan User's Guide and Reference Manual at http://mc-stan.org/.
Details can be found in the Getting started page of the wiki.
The following is the classic 'eight schools' example from Section 5.5 of Gelman et al (2003). The output can be compared to that obtained using the Rstan and Pystan interfaces.
schools_code = {
'data {'
' int<lower=0> J; // number of schools '
' real y[J]; // estimated treatment effects'
' real<lower=0> sigma[J]; // s.e. of effect estimates '
'}'
'parameters {'
' real mu; '
' real<lower=0> tau;'
' real eta[J];'
'}'
'transformed parameters {'
' real theta[J];'
' for (j in 1:J)'
' theta[j] = mu + tau * eta[j];'
'}'
'model {'
' eta ~ normal(0, 1);'
' y ~ normal(theta, sigma);'
'}'
};
schools_dat = struct('J',8,...
'y',[28 8 -3 7 -1 1 18 12],...
'sigma',[15 10 16 11 9 11 10 18]);
fit = stan('model_code',schools_code,'data',schools_dat);
print(fit);
eta = fit.extract('permuted',true).eta;
mean(eta)
A collection of Matlab-specific examples is available in the wiki.
You may be able to find a solution in the wiki. Otherwise, open an issue.
MatlabStan Copyright (c) 2017 Brian Lau [email protected], BSD-3
PSIS package Copyright (c) 2015 Aki Vehtari, GPL-3
Please feel free to fork and contribute!