AMatlabinterfacetoStan,apackageforBayesianinference.
FormoreinformationonStananditsmodelinglanguage,seetheStanUser'sGuideandReferenceManualathttps://mc-stan.org/.
InstallationDetailscanbefoundintheGettingstartedpageofthewiki.
ExampleThefollowingistheclassic'eightschools'examplefromSection5.5ofGelmanetal(2003).TheoutputcanbecomparedtothatobtainedusingtheRstanandPystaninterfaces.
schools_code={'data{''int<lower=0>J;//numberofschools''realy[J];//estimatedtreatmenteffects''real<lower=0>sigma[J];//s.e.ofeffectestimates''}''parameters{''realmu;''real<lower=0>tau;''realeta[J];''}''transformedparameters{''realtheta[J];''for(jin1:J)''theta[j]=mu+tau*eta[j];''}''model{''eta~normal(0,1);''y~normal(theta,sigma);''}'};schools_dat=struct('J',8,...'y',[288-37-111812],...'sigma',[151016119111018]);fit=stan('model_code',schools_code,'data',schools_dat);print(fit);eta=fit.extract('permuted',true).eta;mean(eta)AcollectionofMatlab-specificexamplesisavailableinthewiki.
Needhelp?Youmaybeabletofindasolutioninthewiki.Otherwise,openanissue.
ContributionsMatlabStanCopyright(c)2017BrianLaubrian.lau@upmc.fr,BSD-3
PSISpackageCopyright(c)2015AkiVehtari,GPL-3
Pleasefeelfreetoforkandcontribute!
评论