Hold onto your POSTERIORS and get ready to SAMPLE a statistics channel like you've never seen before. Learn Stan with Ric is a channel that introduces you to the wonderful world of practical Bayesian inference and Bayesian Modelling using the Stan programming language. Everyone, from beginners to seasoned professionals, is welcome!
I'm not sure I understand what you are doing in the step around 17:25 where you used vectorized versions of the probability statements that were previously for loops. You go through the hassle of writing for loops for the code and then seemingly delete them and just say "you can vectorize these instead." What then is the purpose of using the for loop if we can do this instead? It seems far more straightforward to just use the vectorized version than the for loop step before it, thus making the for-loop step somewhat unnecessary and confusing in this video.
Actually, I don't know if you do a video on this, but the biggest challenge I have with Bayesian Statistics is not that I have too little but too much data which makes MCMC slow. I've been trying to use the following to solve this problem, use aggregated data in modelling (Binom Likelihoods for instance), sample more wisely so that not every strata has 10,000 observersations, Think about using variational inference, take smaller samples from my posterior since my models aren't super complicated. What do you think about that? My biggest fear with Bayesian stats is creating models that take too long to run, not having too little data!
Another very useful application of the generated quantities block (timeline 23:40) is to create simulated data that closely matches the model. This is central to a lot of statistical analysis. You can create different models and generate simulated data that looks like that model. You can then use that simulated data in other approaches like machine learning etc.
Thank you very much. A very helpful video. So far a task that could far easier be done using rstanarm but I hope to encounter the higher flexibility of programming directly in Stan. Should you still be planning on producing further videos (which I hope) and should you be accepting requests: As the Bayesian alternative to LASSO apparently Horseshoe priors are great. However, I still have to find a single RU-vid video to explain those and how to use them in an accessible manner. Cheers.
Hi Harmonica! Yes i'm still active, but been caught up with other projects unfortunately. Rstanarm is a great wrapper package, but as you say it's way less flexible. Sure thing - I can do a video on horseshoe priors. Will add it to the list :)
@@learnstanwithric I have been searching for horseshoe as well. I want to create a complex model using the horseshoe but can't figure how to model it! I used brm to get the stan code for horseshoe then try to modify it. But I still can't get it T_T
I think the best intro book is the Stan Manual. You can get your hands dirty there. Otherwise, a book called "The BUGS book" is a another great resource :)
Thanks so much for this. I found this very useful. May I please request that in the future, if you're refactoring code like you did here, that you leave a commented out version of the previous code so that we can eyeball the differences?
It doesnt work for me in Win11. I tried everything, earlier I was getting MSVC error, then I manually put the distutils cfg file. Now it doesnt show that error but still wont compile and shows the gcc error exit code 1, I am using python 3.7.16.
Fantastic. I have been so frustrated ever since they stopped supporting pystan for windows. Had been using rstan on my new computer since I did not know how to install the old version till I saw this.
This is amazing, Ric!! Been using chatGPT to write Spark but using it to write Stan relieves a massive headache! [also love the background music, helps with focus]
Awesome mate! How have you found it's performance in Spark? I think it did an okay job here using Stan, but definitely some weird choices that I'll go through in the next video :)
Many thanks to you... Whatever steps you told here I was doing exactly the same for last two days but in python 3.9... Then today I got your upload and found out that you firstly you installed python 3.7 and second only pystan... And it clicked... Earlier I was doing it successfully in python 3.9 but by mistake I updated some packages and destroyed that all-good setting... Thanks again...
Hello again, your RStan videos which I've watched repeatedly are a treasure trove. They've really helped me to understand the whole process of doing Bayesian inference in Stan. PS: Please where can I find the music in the intro (you described it as 'Soul Hip Hop Beat' by UrbanGodzilla but can't find it anywhere on the web)??? I got to have this its too funky! Any help with this will be great. Thanks again.
Thanks for making this video. I have followed the instructions (I believe) to a "T," however when I try to instantiate the model object, I get the following error: "WARNING:pystan:MSVC compiler is not supported" I downloaded and installed the mingw32 compiler and created the distutils.cfg file, but for some reason I cannot move past this error. My knowledge of this is at it's limit, so I am just wondering if you have any thoughts on what I might be doing wrong. Edit: I just created a fresh new environment (titled "kill_me_now_plz") and ran through the instructions again, and I still encounter the same error. When I run the following, I get an output of "None" which I think may be what triggers the error: from Cython.Build.Inline import _get_build_extension print(_get_build_extension().compiler) I may be off base here, like I said, this is really pushing the bounds of my knowledge and experience.
Hey, you might be putting the distutils.cfg file in the wrong folder or you might have an incompatible version of python. There's some instructions toward the end on how to deal with both of these issues. However, if you're still having trouble, suggest you try a linux install instead using WSL2. I have a video on that as well
This was the best explanation of the Jacobian transform I have ever seen! Incredible graphics and well thought out diagrams! Thank you so much, love this channel!
Saw the plug in R/datascience I subscribed after watching this video. Love it! Like someone else mentioned the current channel name gets swamped by Stanford University in the algo. Cheers
Thank you for the subscription! yes the Stanford Uni is crushing my SEO. I'm thinking about the name change as we speak and will do an updated vid soon. Thanks!
What an incredible and brilliant video! Thank you million times for sharing such invaluable knowledge with me. I am able to follow all the steps and get pystan to run with python. Sorry for asking, but do you see any issues running pystan with jupyter notebook? In the video, you had mentioned about MSVC issues, and completely agree with you. When running jupyter notebook, have you encountered the issue "Unable to find vcvarsall.bat"? Do you have any suggestion on the best way to fix it? Truly appreciate your time and generosity here.
No there shouldn't be any issues with using pystan with Jupyter. All you need to do is make sure that the kernel you are using in your jupyter notebook is the virtual environment you used to install stan. If you were able to get it running in your virtual environment, then there should be no problem with getting it to run in jupyter. Most likely thing that's happening is you're using the wrong kernel in jupyter. After you have installed jupyter, in the console type ipython kernel install --user --name=your_venv_name where your_venv_name is the name of your venv Then when you start your jupyter server, make sure to select the right kernel. Good luck!
@@learnstanwithric Thank you so much for your prompt response. Yes, you are right, I am using the wrong kernel. I am able to get pystan to run now both in jupyter and python- it is literally the happiest moment ever for me this week after countless trying. I am incredibly grateful for your guidance! I will continue to learn more from Stan University.