Questions tagged [pymc]

PyMC is a Python library for performing Bayesian inference using MCMC. It is a Python equivalent to JAGS and BUGS.

263 questions
Filter by
Sorted by
Tagged with
9 views

Statistical Integration of Bayesian and Frequentist Approaches: Weighing Methodology

I'm uncertain about where to post this question. I'm currently working with geotechnical data (soil parameters) and aiming to obtain realistic and safer parameter values. To achieve this goal, I've ...
• 123
34 views

How to take a negative ranged prior using pymc package?

I was trying to fit bayesian linear regression using pymc package. But for certain model coefficients I need to choose the prior as a negative ranged distribution (for example negative halfnormal) so ...
• 21
35 views

Estimating posterior of proportion of positives in population from per-observation probabilities

I have a sample from some population of 0s and 1s and need to estimate the posterior of the proportion of 1s in this population. But the catch is: for each observation in the sample I only have ...
91 views

Why do we need to scale the variables in a Bayesian model?

In a Bayesian MMM model using pymc3 the variables are scaled. It is said that scaling helps in improving the efficiency of the MCMC algorithm. Also, it is stated that setting priors for the non-scaled ...
• 21
15 views

Lots of variability in the effective sample size but stable parameter estimates?

I ran 4 chains with NUTS and made a forest plot, but I cannot show the plot here. In words, what I am seeing is the there is a lot of variability in the effective sample size (ESS) in the chains. ...
• 7,168
136 views

Bayesian meta-analysis: Why and how to weight individual study's contribution to overall effect?

I'm interested in performing a Bayesian meta-analysis, specifically, using a random-effects hierarchical model (as described here). Briefly, in this model we assume that the $k$th study's reported (...
• 43
1 vote
65 views

A Bayesian marginal structural model (IPW) in a single model

Inspired by Richard McElreath's "Full Luxury Bayes" in his Statistical Rethinking course, I wanted to implement a "Full Luxury Bayesian Marginal Structural Model". Briefly: MSMs ...
• 141
11 views

Same relative spread of posterior means in Bayesian Linear Regression

I'm doing a Bayesian Linear Regression based on some marketing data, and pretty much following the tutorial outlined here. To summarise: I aim to predict revenue based on a bunch of different ...
• 151
348 views

How to interpret rank bar plot of a MCMC trace?

I am learning how to use PyMC for Bayesian inference. I coded up a random intercept $Y = \gamma + \sum_{j=1}^3 \beta_j \mathbb{I}_j + \epsilon$ and looked at the trace plots. Here is a ...
• 7,168
472 views

Bayesian regression confidence intervals with Pymc3

This question is based on question 1 of the week 2 Statistical Rethinking problems, i.e. q1 here: https://github.com/rmcelreath/stat_rethinking_2022/blob/main/homework/week02.pdf I have a pandas data ...
302 views

Reason behind only using internal knots when defining basis splines

In the spline regression tutorials of pymc and bambi they first define the knots using quantiles, but for building the design matrix they don't use the boundary knots and only keep the internal knots. ...
143 views

PyMC3 Beta-Binomial fails to converge on actual parameter values

Something is not performing as expected with PyMC. I'm trying a simple Beta-Binomial conjugate prior model, trying to recover known parameters. Control data ...
• 2,507
51 views

Need help explaining Bayesian p-value plot

I'm working through Chapter 2 of BMCP and am having trouble understanding why the plot of a Bayesian p-value looks so unexpectedly "spiky" or multimodal. Here's my code ...
• 176
1 vote
106 views

Modeling with count data as predictors and continuous as outcome variable (Bayesian)

Disclaimer: This is a long explanation but I feel like it was needed to give a thorough description of my problem. Let me know if this question is in the wrong place. I am relatively new to Bayesian ...
• 31
1 vote
105 views

Uncertainty/Error Estimates from RMSE and Confusion Matrix

Would it be advisable to use the F1 score as an 'error', to represent both omission and commission error rates in this areal masking process? Would it be advisable to treat the RMSE and F1 as standard ...
• 121
425 views

Interpret plot_trace from PYMC

New to Bayesian Modeling and the python library PYMC. Got some confusing result. How would an expert on Bayesian modeling interpret these graphs? ...
• 233
1 vote
306 views

Hierarchical Bayesian modeling with count data (PYMC): how to specify this model?

I'm completely new to Bayesian statistics and tried to get a grasp of the fundamentals for a specific case I'm working on. However, I feel like I've led myself down a blind alley and I'm still ...
• 31
154 views

Interpreting posterior with Half-Normal shape

I am building a Marketing Mix Model in PyMC and am not sure how to interpret the posteriors, especially those with half-normal priors (sigma=1). I’ve chosen this prior because media could not have a ...
1 vote
111 views

JAGS model to PyMC [closed]

I'm trying to translate a code that I have written in JAGS to PyMC but I'm getting stuck due to the recursion in the JAGS code that I can't figure out how to pass it to PyMC. The model in JAGS is ...
78 views

How can one estimate a new λ for a Poisson Distribution after changing circumstances?

To fit the question to a problem lets say you have a store in a mall where the rate of customers visiting the store can be modelled as a Poisson Distribution where λ = 3. Now lets say next month ...
• 41
87 views

Why is off-centered prior necessary for HMC sampler?

In this PyMC3 tutorial on Bayesian Mixed Effects Models, there is some Re-parameterization "to avoid chain divergences." ...
• 2,507
36 views

How to deal with low survey response rate and hypothetical question about influence of people not responding?

Background: Imagine you are running a survey, asking 1000 random people: "do you like blue marbles?" Now, 200 people respond. 150 say yes, 50 say no. If I had only sent that survey to only ...
• 301
596 views

What type of prior to choose for one-hot encoded (dummy coded) variables in Bayesian logistic regression?

I'm going through Rethinking and Kruschke's Puppy book. After the examples I want to try myself with other data and have a problem. What if (unlike the examples in the book and online) categorical ...
• 290
1 vote
140 views

Counterfactual Bayesian survival analysis in pymc

I am trying to determine mortality rates for untreated patients from an observational dataset where treatment has occurred (thus blocking the possibility of further untreated mortality). You can't ...
• 73
1 vote
262 views

Weibull Proportional Hazard in pymc

I’m looking to create a Bayesian proportional hazard model where the baseline hazard is modeled by a Weibull distribution (or some similar continuous distribution). I’ve reviewed (and implemented) the ...
• 73
1 vote
2k views

Pymc3 SamplingError: Initial evaluation of model at starting point failed

I am working on a Bayesian Cox Proportional Hazard model. I've started by implementing and running the Bayesian CPH example at https://docs.pymc.io/en/stable/pymc-examples/examples/survival_analysis/...
• 73
1 vote
124 views

Posterior distributions --- what's the correct way to see it?

When running models from a bayesian perspective — a regression for example — we get posterior distribution for every parameter/statistic we want, right? I’m wondering whether I should see this this ...
• 561
1k views

Relationship between laplace and l1 regularization

It is well known that an L1 regularized linear regression is equivalent to a regression with a Laplace prior on the distribution of the coefficients. This is explained here: https://bjlkeng.github.io/...
196 views

Mass matrix error with degree of freedom and scale parameters of Student T distribution?

I have been working using the following codes to acquire the Bayesian Fusion of StudentT distribution. Fusion code: ...
• 101
77 views

How to Build a Model with Correlation / Statistical Dependency for Bayesian A / B Testing

I use the Beta Binomial model for A/B testing. I wonder if there a way to build a model in PyMC which models correlation between the conversion rate of group A with ...
• 277
165 views

Inconsistent posterior estimates in Beta-Binomial likelihood vs Binomial in Bayesian, multilevel models?

In this Google Colab, I've simulated Binomial count data and compared the performance of Binomial-likelihood and Beta-Binomial-likelihood models. Both models have the same Beta prior on theta, the ...
• 2,507
92 views

Bayesian regression for the sum of Gaussians

I'm pretty new to Bayesian statistics and I want to use Bayesian regression on a 2D data set (frequency on x-axis and measurement data on the y-axis) to quantify the uncertainties. The model is a ...
73 views

How can we attribute observations to observers in a hierarchical Bayesian model?

I am trying to make a hierarchical Bayesian model of latent variables based on many observations by noisy oracles. I want to leverage the information of which observations are from which oracles, as I ...
• 101
1 vote
255 views

Observation dependency in pymc3 models

I have a model, which can be simplified conceptually to: $$a \sim TruncNormal(\mu = 1.0, \sigma=0.01, min = 0.9, max = 1.1)$$ $$y = a \cdot sin(b)$$ I can make observations about $y$, but these ...
• 113
1 vote
2k views

How to generate posterior predictive samples with size different than the observed variable in pymc3?

I have a simple probabilistic model with Beta prior and Bernoulli likelihood: ...
• 123
206 views

Explanation of differential equation solution in survival analysis proof

I follow all the steps in the below derivation until the third to last line, "solving this differential equation for the survival analysis function shows that..." Questions I never took ...
• 2,507
84 views

How are differential equations and stochastic differential equations different?

In the simplest terms, how are differential equations and stochastic differential equations different? As far as I can tell, SDEs are PDEs or ODEs, where the derivative of some function wrt itself is ...
• 2,507
668 views

difference of means of non-normal data using Bayesian model

I have two distributions, group 'c1' and 'c2' that are not normally distributed, but rather log-normal: Now, I'd like to compare the means between 'c1' and 'c2' using bayesian methods, as described ...
• 131
1 vote
715 views

Why do Pareto/NBD models require custom likelihood functions in PyMC3 and Stan?

I'm interested in Bayesian modeling of customer lifetime value (CLV), preferably via PyMC3. I've found that research in this area started mid-to-late 1900's and has remained active since. It would ...
• 2,507
2k views

PyMC3 implementation of Bayesian MMM: poor posterior inference

Google released a whitepaper on Media Mix Modelling (MMM) in 2017; vanilla MMM (established in the 1960s) uses multivariate regression. It's a decent mechanism to understand which of your marketing ...
• 2,507
907 views

Meaning of design matrix in context of Bayesian B-Spline regression?

I'm learning about modeling B-Splines using PyMC3. The design matrix of splines (apparently) can become quite complicated, so it's easier to delegate this construction to an API, Patsy. In the context ...
• 2,507
404 views

Spline regression via PyMC3

I've looked through PyMC3 documentation and haven't seen any tutorials/resources on learning to use Splines w/ PyMC3. Could anyone recommend a resource? I see that Stan tutorials are available. I ...
• 2,507
39 views

Unexpected zero on posterior density of Dirichlet process mixture

I was reading this notebook from the PyMC3 documentation about Dirichlet Process Mixtures and, on the last figure, the estimated density reaches almost zero for a particular value, despite the ...
• 2,663
187 views

Multivariate bayesian parameter estimation

I am implementing an example for pymc3 in python and I want to understand the mathematical formulation of this code. ...
270 views

Confused about the necessity of multplying the covariance function by a scaling factor in Gaussian Process modeling

I was reviewing examples of implementing GP-based model with PyMC3. I noticed some examples will multiply the covairance function by a factor, which is in turn modeled as a random variable, while ...
• 215
131 views

Estimating the number of apples in an apple tree using MCMC

I'm trying to estimate the number of apples in an apple tree by repeatedly kicking the tree and counting how many apples fall down. This process, I believe, is called removal sampling. The only ...
• 87
75 views

How can PyMC3 handle uncertainty in the number of parameters in a Dirichlet Distribution?

I'm taking a look at the following to familiarize myself with Bayesian Inference in PyMC3: https://towardsdatascience.com/estimating-probabilities-with-bayesian-modeling-in-python-7144be007815 In this,...
1 vote
636 views

Sequential updating in Bayesian Inference - pymc3

I am trying to implement the following research paper in pymc3 - https://people.ok.ubc.ca/pgill/research/cricketsim.pdf. In short, this research paper tries to model cricket matches and simulate the ...
• 113
1 vote