r/BayesianProgramming • • Mar 04 '23

Bayesian logistic regression with Rethinking package in R

4 Upvotes

Hi all,

This question is for those familiar with the rethinking package in R. I think I am struggling to correctly specify a logistic regression model with the rethinking package and need help understanding what I am doing wrong.

I am trying to use a logistic regression model to estimate the probability of voting for candidate A (vs candidate B) in 6 different groups of voters. The raw percentages of study participants voting for candidate A in each group are as follows:

Group 1 (n=398): 0.2%

Group 2 (n=35): 17%

Group 3 (n=10): 80%

Group 4 (n=18): 89%

Group 5 (n=59): 92%

Group 6 (n=176): 99%

However, when I fit a Bayesian binomial logistic regression model using quap() to estimate the proportions and intervals for each group, I get something totally different.

Here is my R code:

m.2020vtq <- quap(

alist(

vote ~ dbinom(1, p),

logit(p) <- a[cgroup],

a[cgroup] ~ dnorm(0, 0.5)

), data = da3)

post <- extract.samples(m.2020vtq)

pvt <- inv_logit(post$a)

plot(precis(as.data.frame(pvt),depth = 2, prob = 0.95), xlim(0,1))

Here are the posterior estimates (mean and 95% CI's) from the model.

What am I doing wrong in my code? Why are the model’s estimates of the probability of voting for candidate A so off from the raw counts? Why is the estimate of those voting in group 6 a probability of 0.5 when 99% of participants in that group voted for candidate A? Does it have to do with my priors?

I greatly appreciate any help you are willing to give. From a new student of Bayesian modeling, thank you!


r/BayesianProgramming • • May 24 '22

I need help with my homework I have been struggling with this for days

Post image
4 Upvotes

r/BayesianProgramming • • Aug 19 '21

High-dimensional Bayesian regularized regression

4 Upvotes

Hi folks,

A beginner in Bayesian programming out here. I'm currently working on a neuroscience project where I will be using bayesreg to find clinical and demographic predictors of the occurrence of cerebral microbleeds (the implementation will be in MATLAB).

For those of you familiar with penalized regression models and high-dimensional regularized regression in particular, could you recommend any beginner-friendly articles or YouTube videos/video series (not books preferably as I have a very limited amount of time to get the basics of RR, lol) that have helped you?

Thanks in advance! :)


r/BayesianProgramming • • Dec 12 '20

Bayesian models to compute performance and uncertainty of returns and alpha.

Thumbnail
github.com
4 Upvotes

r/BayesianProgramming • • Dec 12 '20

Bayesian Portfolio Allocation – Thalesians

Thumbnail
thalesians.com
4 Upvotes

r/BayesianProgramming • • Aug 29 '20

Bayesian Media Mix Modeling using PyMC3, for Fun and Profit

4 Upvotes

This post explains our implementations of a Baysian Media Mix Model: A predictive analytics tool used to optimize media budgets of larger advertisers with many marketing channels. Would love to hear your thoughts!

Bayesian Media Mix Modeling using PyMC3, for Fun and Profit


r/BayesianProgramming • • Jul 19 '20

AutoPPL: C++ Template Library for Probabilistic Programming

4 Upvotes

Hi everyone,

I posted about this in a different subreddit post and I wanted to share it here as well since it's very much relevant. This library is nowhere close to being done and still needs a lot of work (contributors are welcome), but it has been quite successful for some simple models. The link to the Github repo shows some benchmarks with STAN as well. I would love to get some feedbacks and comments from this community as well!


r/BayesianProgramming • • Dec 13 '19

Please help! Been struggling with this question for days! More so the derivations and not the code.

Post image
4 Upvotes

r/BayesianProgramming • • Nov 28 '19

Bayesian Interview

4 Upvotes

I have an interview tomorrow (arranged today) for a job which mainly requires Bayesian Statistics, for an Analyst position. The company is in a huge hurry and if I don’t sound stupid they will hire me on the spot.

I am a physicist and know the very basics of Bayesian Statistics. If you were to choose something CRUCIAL that would make me look as if I was more literate in the field, what would it be?

Please Reddit do your magic!


r/BayesianProgramming • • Sep 05 '19

GSoC 2019: It’s Over! - Ph.Demetri

Thumbnail
dpananos.github.io
4 Upvotes

r/BayesianProgramming • • Aug 16 '19

My posterior is my prior

4 Upvotes

Just joined this group. Is the group for beginners or more advance topics? Or are anything topic welcome?


r/BayesianProgramming • • Apr 14 '19

Negative probabilities in graphical models? State-dependent weights?

Thumbnail
reddit.com
4 Upvotes

r/BayesianProgramming • • Mar 21 '19

Structural Time Series modeling in TensorFlow Probability

Thumbnail
medium.com
4 Upvotes

r/BayesianProgramming • • Nov 19 '18

Inteview with Thomas Wiecki about Probabilistic programming and PyMC

Thumbnail
notamonadtutorial.com
4 Upvotes

r/BayesianProgramming • • Nov 07 '18

Practical probabilistic machine learning in Python

Thumbnail
github.com
4 Upvotes

r/BayesianProgramming • • Oct 23 '18

A Thorough Introduction to Boltzmann Machines

Thumbnail
willwolf.io
4 Upvotes

r/BayesianProgramming • • Sep 02 '18

Keeping Up with the Bayeses

4 Upvotes

I'm more and more becoming a Bayesian. While there's still plenty for me to learn about the foundational/intermediate stuff, I'm starting to wonder how you all (if you do) keep up with current research in Bayesian statistics/machine learning/programming.

arXiv especially can already be a bit like trying to drink from a fire hose as is, and I could look for titles with obvious clues like "Bayesian," "probabilistic," etc. in the title, but is there something more systematic?

What are the names/schools/journals I should keep my eye for?

Like I said, I'm still a little ways off from consuming the latest research, but I'm the kind of person who reads the last chapter of the book first so I know what it's all building to - helps me visualize the learning path.

Edit: fixed some weird formatting


r/BayesianProgramming • • Mar 29 '18

ABrox—A user-friendly Python module for approximate Bayesian computation with a focus on model comparison

Thumbnail
journals.plos.org
4 Upvotes

r/BayesianProgramming • • Mar 24 '18

Financial forecasting with probabilistic programming and Pyro

Thumbnail
medium.com
4 Upvotes

r/BayesianProgramming • • Mar 07 '18

Bayesian Changepoint Detection with PyMC3

Thumbnail
cscherrer.github.io
4 Upvotes

r/BayesianProgramming • • Oct 13 '17

Bayesian Nonparametrics – Stats and Bots

Thumbnail
blog.statsbot.co
4 Upvotes

r/BayesianProgramming • • Oct 12 '17

Bayesian Time Varying Coefficients in PYMC3

Thumbnail
barnesanalytics.com
4 Upvotes

r/BayesianProgramming • • Oct 12 '17

2016 Voter Turnout in NJ Municipalities was Strongly Correlated with Income — Unbury the Lead

Thumbnail
unburythelead.com
4 Upvotes

r/BayesianProgramming • • Aug 02 '17

Thomas Wiecki on Probabilistic Programming with PyMC3

Thumbnail
blog.fastforwardlabs.com
4 Upvotes