Skip to content
/ MatlabStan Public

Matlab interface to Stan, a package for Bayesian inference

# brian-lau/MatlabStan

Switch branches/tags
Could not load branches
Nothing to show

# Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

## Files

Failed to load latest commit information.
Type
Name
Commit time

# MatlabStan

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!

## About

Matlab interface to Stan, a package for Bayesian inference

v2.15.1.0 Latest
May 15, 2017

## Packages 0

No packages published

•
•