MatlabStan

授权协议 BSD-3-Clause License
开发语言
所属分类 应用工具、 科研计算工具
软件类型 开源软件
地区 不详
投 递 者 巫马正卿
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

MatlabStan

Stan Logo

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/.

Installation

Details can be found in the Getting started page of the wiki.

Example

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.

Need help?

You may be able to find a solution in the wiki. Otherwise, open an issue.

Contributions

MatlabStan Copyright (c) 2017 Brian Lau brian.lau@upmc.fr, BSD-3

PSIS package Copyright (c) 2015 Aki Vehtari, GPL-3

Please feel free to fork and contribute!