9 ms·
Stan is a state-of-the-art platform for statistical modeling
- dstick 6y agoMy name is Stan and I just finished a feature on the product I’m working on that used statistical analysis for anomaly detection. So this headline made me smile - thanks for sharing, and apologies for a rather pointless comment otherwise ;-)
- PLenz 6y agoStan is one of those technologies I keep finding is actually powering the more 'friendly' interfaces I run to one off jobs - especially in the mcmc world. Every so often I think I'll spend some time to learn stan proper but it's such an all-encompassing project that I get intimidated and stick to the derivatives. My loss! Bravo to the team behind it and for making and supporting such a powerful tool!
- deugtniet 6y agoI've dabbled in Stan, and it's really good and state of the art for Bayesian inference. Starting using Stan is a bit difficult though, as it has a C like programming language that is difficult to master initially. Especially since statistics is usually done in languages like R, so the learning curve is a bit steep for beginners. I've personally liked PyMC for simple models and relative ease of inference, as it's more integrated with the Python language. That being said, if you want the latest in inference methods and statistical alchemy, Stan is the place to go.
- phillc73 6y agoThere are a good range of other programming language interfaces to Stan. The R one is quite popular.[1] You do still need the C++ toolchain, but can just write your code in R. [1] https://mc-stan.org/rstan/ https://mc-stan.org/rstan/
- melling 6y agoThere’s a Julia Stan too: http://stanjulia.github.io/Stan.jl/stable/INTRO.html http://stanjulia.github.io/Stan.jl/stable/INTRO.html https://astrostatistics.psu.edu/su14/lectures/BayesComp2014LabMCMCv1.pdf https://astrostatistics.psu.edu/su14/lectures/BayesComp2014L...
- standevbob 6y agoStan requires models to be coded in the Stan language, which is a simple imperative language that's like MATLAB with explicit data types. This is the same as was done in Stan's predecessors, BUGS and JAGS. A Stan program can be run in any of our interfaces in Python, Julia, R, MATLAB, Stata, etc. But you can't mix any of those languages into a Stan program. The C++ toolchain is required because Stan transpiles its programs to C++, then compiles those against the Stan math librarym, which does autodiff. But you don't need to write any C++ to use Stan, just to develop extensions for it.
- ogogmad 6y agoObligatory question: What applications does Stan have? I'm aware of Facebook's Prophet model for time series prediction, but what about others? I find there's a lot of excitement around Bayesian inference and MCMC, but I do wonder about the substance.
- stdbrouw 6y agoAny kind of statistical modeling that doesn't fit neatly into an existing "one (meta)model to rule them all" framework such as generalized linear models.
- usgroup 6y agoI don't think that's accurate. Sampling based approaches scale badly with data so, although there are a few exceptions, if you're tackling the problem as a hierarchical Bayesian model - which is most often what Stan is used for - you're working with a dataset with a small number of features and fewer than 10k rows. Stan fittings can be made parallel, some models will scale linearly with the data, but in the main you won't find many big data use cases here. You also can't use Stan for online learning.
- stdbrouw 6y agoFair enough. I read the word "application" as "field of inquiry" where I do think the sky is the limit, but it's true that Stan is primarily geared towards scientific work with small data sets.
- harperlee 6y ago> You also can't use Stan for online learning. Can’t you loop posteriors as next iterations priors to get a system that learns online?
- ploika 6y agoYou can, but it's slow and computationally intensive - you still need to be fairly sure that the sampler has converged on the true posterior (I might be a bit off with the terminology there but you know what I mean) before that can become your new prior.
- wodenokoto 6y agoWhat kind of problems does Stan / Bayesian inference beat the much more hyped Tensorflow / deep learning approach? Often you hear that deep learning is best at unstructured data (images, sound and recently raw text) and boosted trees / XG boost for tabular data.
- usgroup 6y agoStan is exceptional if what you need is a hierarchical Bayesian model, and if what you want is rigorous way of quantifying the uncertainty associated in the parameter selections in your model. Stan users are more often R users than Python user and mostly come from science backgrounds. They often use Stan via a package called BRMS which stands for "Bayesian Regression Models using Stan" which should give you some idea of its core use case. You wouldn't use Stan if you weren't trying to model your problem as a distribution based probabilistic model.
- scottfr 6y agoStan: Predict the values of parameters in a model Deep Learning: Predict an outcome variable For example, if I want to know what effect household income has on a student's chance of getting into college, Stan would allow you to estimate that given a proposed model. If instead I wanted to predict a given student's chance of getting into college, I might use Machine Learning. Of course, those two problems are linked, but it's a fundamental difference of focus.
- deleted 6y ago[deleted]
- deleted 6y ago[deleted]
- nightski 6y agoWhile it is true that Bayesian inference is very powerful in that it allows one to introspect and view effects of the model's parameters on the outcome, it is equally as good at predicting the outcome variable as well. It just depends on what you want to get out of it. In fact you get more information about your outcome variable from Bayesian Inference as it is a distribution. I'm not saying it is better than DL by any means, as DL can scale much better. Just that I don't think it's necessary to pigeonhole Bayesian inference to just predicting the parameters. In my opinion the "fundamental difference of focus" is just a personal decision, not something inherent to the method.
- pvitz 6y agoBy looking at the user's guide, it seem that Stan has also other use cases than Bayesian inference. Examples are linear regression, mixture models and even ODEs. Does anybody here have experience with Stan and R and could comment on the strengths of Stan in non-Bayesian contexts?
- Crye 6y agoI don't know what your experience with Bayesian modeling is, and I'll admit mine is limited, but STAN can solve linear regression by defining up a linear model and then setting the dimension parameters as a normal distribution to solve. This is great because it gives you a measure of certainty for each of your parameters.
- elsherbini 6y agoStan uses MCMC (specifically NUTS, which is a Hamiltonian Monte Carlo sampler) to optimize parameter fitting, so it can be used for things like ODEs. Here is an example from a class taught last January that uses stan to fit a simple ODE (using the `integrate_ode_rk45` function in stan): https://github.com/gregbritten/BayesianEcosystems_IAP/blob/master/notebooks/npzF_stan_pred.ipynb https://github.com/gregbritten/BayesianEcosystems_IAP/blob/m...
- currymj 6y agoI believe the main reason for including ODE solvers is basically to do Bayesian parameter estimation of ODEs from data. likewise as far as I know, linear regression and mixture models are both done in a Bayesian style (a hierarchical model giving priors for parameters).
- standevbob 6y agoStan provides both frequentist inference (penalized maximum likelihood with bootstrapped confidence intervals) and Bayesian inference (MCMC sampling or approximate variational) inference. As currymj says, the differential equations (same for all the linear algebra solvers like eigendecomposition) can be used in defining likelihoods for either Bayesian or frequentist estimation. Same for all of our linear algebra operations and special functions. Not every model that can be programmed in Stan has a well-defined MLE or proper posterior. Standard hierarchical/multilevel models don't have MLEs, even with standard shrinkage. Bayesian models with improper priors and no data wind up with improper posteriors, etc. Having said all that, almost all of the use of Stan is for Bayesian inference.
- money28 6y agokwqeqw
- mushufasa 6y agoDoes anyone know of a good article of a comparison between Stan vs PyMC3 for real-world bayesian modelling tasks? E.g. to be used in a production system.
- elsherbini 6y agoDoes anyone know what a practical upper limit is for Stan in terms of size of data set / number of parameters to fit? Can you use stan to fit a model with ~10^4 parameters and ~10^6 rows of data if you had access to ~10^3 cores? How long would it take?
- gbrown 6y agoI imagine it depends on which algorithm you’re using - maybe with their VB functionality (I almost entirely use the souped up NUTS algorithm for full Bayesian inference). It also likely depends on how well conditioned your model is - even if you can get it to run for huge models on reasonable hardware, convergence may not be practical.
- hendzen 6y agoStan used to only be able to parallelize across chains but they introduced within-chain parallelism this year. Even then some of the work is still serial so I don’t think you can expect linear speedups past a certain point.
- standevbob 6y agoYes, we regularly use Stan's MCMC to fit relatively simple time-series regression models or item-response theory type models with 10^5 parameters and 10^6 rows of data on a desktop computer. It can take a day, though. It's much faster with variational inference, but that can be less stable and it doesn't give you the same uncertainty quantification because of the way the KL-divergence is ordered in the objective. Stan can parallelize multiple chains and it can parallelize the density/gradient calculations in a single chain. But for the latter to be efficient, the chunks being parallelized need to be compute intensive, like you might get in a pharmacometric compartment model where you might have to solve a bunch of differential equations for each of thousands of patients in a clinical trial.
- hendzen 6y agoIf you want to learn Stan I highly recommend the book Statistical Rethinking (2nd Ed) by Richard McElreath. It’s a pedagogical masterpiece and light years away the best resource I’ve found on learning Bayesian inference.
- elsherbini 6y agoSeconded. He has a full course on youtube as well, and a free version of the textbook that is just missing the last chapter available on his website (password is in the first or second lecture on youtube) https://www.youtube.com/watch?v=4WVelCswXo4&list=PLDcUM9US4XdNM4Edgs7weiyIguLSToZRI https://www.youtube.com/watch?v=4WVelCswXo4&list=PLDcUM9US4X...
- agravier 6y agoFirst. blossom.
- nextos 6y agoStatistical Rethinking is not bad, but I think it's for people with backgrounds different than CS (or Math). Personally, I think https://probmods.org/ https://probmods.org/ is an exceptionally good introduction to probabilistic programming for someone that knows CS or just some programming and likes a SICP-like textbook that goes into the essence of the topic. Learning Stan is great, but not as a first probabilistic programming language, because it's quite limited (it trades model expressiveness for performance). So you can't represent a large set of models, such as infinite mixtures, which may become really relevant in the future developments of deep learning. It also has poor performance in models that involve many discrete variables.
- stevesimmons 6y agoThe Statistical Rethinking book uses R. For people wanting Python, Jupyter notebooks with Python code examples are here: * https://github.com/pymc-devs/resources/tree/master/Rethinking_2 https://github.com/pymc-devs/resources/tree/master/Rethinkin...
- mark_l_watson 6y agoI will give PyStan a try over the holidays. Also, many thanks for all of the great comments here (statistical modeling is not in my toolbox yet, and the discussion here is grounding).
- glial 6y agoFacebook’s (very good) Prophet forecasting library is a wrapper for Stan models. https://facebook.github.io/prophet/ https://facebook.github.io/prophet/
- astrophysician 6y agoJust to clarify: prophet implements a particular model with Stan as a backend, not Stan models generally.