Questions tagged [pymc]

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

Filter by
Sorted by
Tagged with
21 votes
1 answer
7k views

Getting started with bayesian structural models using MCMC

I'm trying to learn bayesian structural time series analysis. For a variety of reasons I need to use Python (mostly pymc3) not R so please do not suggest the ...
Paul's user avatar
  • 365
19 votes
1 answer
11k views

Bayesian network inference using pymc (Beginner's confusion)

I am currently taking the PGM course by Daphne Koller on Coursera. In that, we generally model a Bayesian Network as a cause and effect directed graph of the variables which are part of the observed ...
zubinmehta's user avatar
16 votes
1 answer
913 views

COVID in Germany, LOO-CV for time series

The paper in Science [1] infers change points in COVID spread in Germany. The authors fit the number of daily cases assuming one (red), two (orange), and three (green) change points. Every change ...
slitvinov's user avatar
  • 135
13 votes
2 answers
2k views

Why are there recommendations against using Jeffreys or entropy based priors for MCMC samplers?

On their wiki page, the developers of Stan state: Some principles we don't like: invariance, Jeffreys, entropy Instead, I see a lot of normal distribution recommendation. So far I used Bayesian ...
wirrbel's user avatar
  • 615
13 votes
2 answers
7k views

PyMC beginner: how to actually sample from the fitted model

I'm trying a very simple model: fitting a Normal where I assume I know the precision, and I just want to find the mean. The code below seems to fit the Normal correctly. But after fitting, I want to ...
jmmcd's user avatar
  • 363
13 votes
1 answer
5k views

Bayesian model selection in PyMC3

I am using PyMC3 to run Bayesian models on my data. I am new to Bayesian modeling but according to some blogs posts, Wikipedia and QA from this site, it seems to be a valid approach to use Bayes ...
hadim's user avatar
  • 234
13 votes
2 answers
10k views

What is pm.Potential in PyMC3?

I'm going through the Price Is Right example in chapter 5 of Probabilistic Programming & Bayesian Methods for Hackers. It reads: Example: Optimizing for the Showcase on The Price is Right ...
JPN's user avatar
  • 826
12 votes
2 answers
6k views

Fitting model for two normal distributions in PyMC

Since I'm a software engineer trying to learn more stats you'll have to forgive me before I even start, this is serious newb territory... I've been learning PyMC and working through some really (...
mat kelcey's user avatar
12 votes
1 answer
3k views

Bayesian modeling of train wait times: The model definition

This is my first attempt for somebody coming from the frequentist camp to do Bayesian data analysis. I read a number of tutorials and few chapters from Bayesian Data Analysis by A. Gelman. As the ...
Vladislavs Dovgalecs's user avatar
11 votes
2 answers
3k views

Probabilistic programming vs "traditional" ML

I was browsing the github repo for Pymc and found this notebook: Variational Inference: Bayesian Neural Networks The author extols the virtues of bayesian/probabilistic programming but then goes on ...
RNs_Ghost's user avatar
  • 864
11 votes
1 answer
1k views

Hierarchical Bayesian modeling of incidence rates

Kevin Murphy's book discusses a classical Hierarchical Bayesian problem (originally discussed in Johnson and Albert, 1999, p24): Suppose that we are trying to ...
Amelio Vazquez-Reina's user avatar
11 votes
1 answer
2k views

Outlier detection in beta distributions

Say I have a large sample of values in $[0,1]$. I would like to estimate the underlying $\text{Beta}(\alpha, \beta)$ distribution. The majority of the samples come from this assumed $\text{Beta}(\...
Amelio Vazquez-Reina's user avatar
10 votes
3 answers
7k views

PyMC: how can I define a function of two stochastic variables, with no closed-form distribution?

I'm learning PyMC and basically I have a random variable $Z = X + Y$ where (say) $X \sim \mathrm{Normal}(\theta_X)$ and $Y \sim \mathrm{Lognormal}(\theta_Y)$ and $Z$ has no simple closed-form ...
roger_'s user avatar
  • 381
10 votes
3 answers
8k views

2-Gaussian mixture model inference with MCMC and PyMC

The problem I want fit the model parameters of a simple 2-Gaussian mixture population. Given all the hype around Bayesian methods I want to understand if for this problem Bayesian inference is a ...
user2304916's user avatar
10 votes
2 answers
7k views

PyMC for nonparametric clustering: Dirichlet process to estimate Gaussian mixture's parameters fails to cluster

Problem setup One of the first toy problems I wanted to apply PyMC to is nonparametric clustering: given some data, model it as a Gaussian mixture, and learn the number of clusters and each cluster's ...
Ahmed Fasih's user avatar
9 votes
2 answers
2k views

Switchpoint detection with probabilistic programming (pymc)

I'm currently reading the Probabilistic Programming and Bayesian Methods for Hackers "book". I've read a few chapters and I was thinking on the first Chapter where the first example with pymc consist ...
Olivier_s_j's user avatar
  • 1,185
9 votes
1 answer
6k views

Advice on sensitivity analysis for priors in Bayesian statistics

I'm not clear on how to perform sensitivity analysis on the priors. Many sites have different answers. One site indicates to perform three non-informative, weakly informative and known priors. Another ...
user3460430's user avatar
9 votes
1 answer
2k views

Using empirical priors in PyMC

I'm using PyMC to sample the posterior distribution and I've run into a roadblock with using priors from samples, not models. My situation is as follows: I have some empirical data for a parameter $z$...
jake's user avatar
  • 91
8 votes
1 answer
590 views

Estimating Failure Rate from Observed Data

I recently read the excellent book Probabilistic Programming & Bayesian Methods for Hackers and I'm trying to solve some problems on my own: I perform an experiment to estimate the reliability ...
mchangun's user avatar
  • 499
8 votes
2 answers
2k views

Regression Mixture in PYMC3

I'm attempting a problem where I have a mixture of regression coefficients. Not sure if my math or my coding is bad, but I'm getting wrong estimates for the coefficients, which should be 5 and -5. I ...
degenerate hessian's user avatar
8 votes
1 answer
2k views

How to use a Hidden Markov Model to detect state in a time series?

Questions Am I right in assuming that the emission probabilities will not be following a gaussian distribution for my particular problem? Obviously, I will need to train the model for state detection....
Raoul's user avatar
  • 309
8 votes
1 answer
2k views

Hierarchical Bayesian analysis on difference of proportions

Why Hierarchical? : I've tried researching this problem, and from what I understand, this is a "hierarchical" problem, because you are making observations about observations from a population, rather ...
Fabio Beltramini's user avatar
8 votes
1 answer
411 views

Plotting a "posterior median surface"

As part of reproducing a model I described partially in this question on Stack Overflow, I want to obtain a plot of a posterior distribution. The (spatial) model describes the selling price of some ...
r_31415's user avatar
  • 3,301
8 votes
1 answer
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 ...
jbuddy_13's user avatar
  • 2,507
8 votes
0 answers
501 views

Bayes Net Parameter Learning in pymc

My goal is to infer the conditional probability tables (CPT) from the classic rain, sprinker, wet grass problem. Normally in this problem we know the CPTs and, given an observation like "the grass is ...
cwharland's user avatar
  • 360
7 votes
2 answers
2k views

Bayes-factor for testing a null-hypothesis?

I heard somewhere, that I can directly test (or gather support for) a null-hypothesis using the Bayes-Factor. In my specific experiment, I hypothesize that an experimental manipulation does not have ...
thias's user avatar
  • 965
7 votes
1 answer
319 views

What is the relationship between graphical models (such as in the Koller book) and the type of analysis you can do with pyMC?

I'm somewhat familiar with the contents of the Koller Probabilistic Graphical Models book (followed some of the Coursera course but didn't have time to do all the homework). I'd recently had the ...
qhfgva's user avatar
  • 153
7 votes
2 answers
6k views

Bayesian recurrent neural network with keras and pymc3/edward

I have a very simple toy recurrent neural network implemented in keras which, given an input of N integers will return their mean value. I would like to be able to modify this to a bayesian neural ...
JMzance's user avatar
  • 274
7 votes
1 answer
864 views

Stochastic Programming with MCMC

While there are far superior methods for solving deterministic LP problems (e.g. interior point algorithms), can MCMC be used to solve their stochastic variants? By stochastic, I mean, for example, ...
Amelio Vazquez-Reina's user avatar
7 votes
0 answers
390 views

Robust Gamma Regression

I am modeling some spectroscopic data where the response of the instrument to the size of the input is strictly positive and non-linear. Gamma regression seems like a good choice to explain the data, ...
udushu's user avatar
  • 223
6 votes
1 answer
6k views

Latent Dirichlet Allocation in PyMC

As an exercise to improve my skills in PyMC (Python's Markov chain Monte Carlo library), I am trying to implement Latent Dirichlet Allocation as described here: https://en.wikipedia.org/wiki/...
Folgert Karsdorp's user avatar
6 votes
2 answers
4k views

Optimize starting parameters for Bayesian Linear Regression?

I'm using PyMC3 in Python 3 and I'm not sure exactly how to optimize my starting parameters. The example uses the regression ...
O.rka's user avatar
  • 1,442
6 votes
1 answer
2k views

PyMC3 Implementation of Probabilistic Matrix Factorization (PMF): MAP produces all 0s

I've started working with pymc3 over the past few days, and after getting a feel for the basics, I've tried implementing the Probabilistic Matrix Factorization model. For validation, I use a subset ...
Mack's user avatar
  • 162
6 votes
1 answer
2k views

Implementing an ordered probit model in pymc [closed]

I'm trying to implement an ordered probit model in pymc, and I'm stuck. The model is similar to Welinder's "multidimensional wisdom of crowds", with coders (indexed by i) and documents (indexed by j)....
Abe's user avatar
  • 1,370
6 votes
1 answer
622 views

computing the posterior of two Gaussian probability distributions

I am a bit confused how to solve a Bayesian statistics problem. I have a parameter $\epsilon^s$ which is defined as following: $$\epsilon^s=\frac{\epsilon-g(\pi,z)}{1-g^*(\pi,z)\epsilon}$$ where $...
Dalek's user avatar
  • 117
6 votes
1 answer
1k views

Modelling Time Series of Ratios

I’m having difficulties dealing with a time series of relations between two numbers. I have two time series, essentially a count of "successes" and "trials". What I'm interested in, though, is the ...
Daniel Liberali's user avatar
5 votes
1 answer
357 views

MCMC Modelling - can this even be solved?

I am very new to Bayesian modelling and MCMC - I would like to know if the problem I describe below can be solved. It seems to be there is too much missing information but I wanted to get your ...
mchangun's user avatar
  • 499
5 votes
1 answer
3k views

pymc3: acceptance probabilities and divergencies after tuning

I coded two models in pymc3, which I thought are quite simple. Logistic Regression The first is a logistic regression in an experiment that models correct and wrong answers for specific tasks in a ...
wiggalicious's user avatar
5 votes
2 answers
8k views

How to generate the posterior predictive distribution for hierarchal model in PYMC3

See iPython notebook for full example The below stochastic node y_pred enables me to generate the posterior predictive distribution: ...
Mark Regan's user avatar
5 votes
3 answers
1k views

Understanding factor potentials in PyMC

I'm trying to understand factor potentials from the PyMC documentation, but need some help on the implementation piece--or it may turn out that I am misunderstanding how potentials work altogether. ...
degenerate hessian's user avatar
5 votes
1 answer
3k views

Bernoulli variable on pymc

Im not fully sure that this is the right place to ask, but I have a problem with pymc that I'm not able to grasp. I'm trying to simulate a simple counting under two different scenario: Under the ...
EnricoGiampieri's user avatar
5 votes
2 answers
428 views

Efficient MCMC using the normal approximation of the posterior

I can usually quickly get the normal approximation of the posterior distribution, but I sometimes struggle with setting up an efficient MCMC of the same model. Can I somehow use the results of the ...
winerd's user avatar
  • 599
5 votes
1 answer
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 ...
Galen's user avatar
  • 7,168
5 votes
1 answer
3k views

How to build a PyMC model to detect multiple 'switch points'?

In 'Bayesian Methods for Hackers' first chapter, Cam Davidson-Pilon presents an example model for detecting at what time point did a user's frequency of text-messaging changed. This model assumes a ...
guest6012's user avatar
  • 151
5 votes
1 answer
2k views

Finding the Poisson rate parameter with PyMC3

I'm trying to compute the rate parameter of fake set of poisson data, where I set the parameter. When I run PyMC the posterior distribution always peaks around the true rate parameter, but never ...
RNs_Ghost's user avatar
  • 864
5 votes
1 answer
2k views

PyMC3; create simple Linear Regression model with real-world datasets

The Linear Model I understand the concepts of Bayesian Inference in that the observed data, $x$, is fixed, and the parameters, $\theta$, are the random variables that follow a particular distribution....
O.rka's user avatar
  • 1,442
5 votes
1 answer
2k views

PyMC for Categorical Latent Model

I'm learning PyMC and am trying to fit a simple categorical mixture model but the sampling estimates don't converge to the true values. I'm wondering if I've specified the model incorrectly or am ...
antianticamper's user avatar
5 votes
1 answer
1k views

Observed deterministic variables in MCMC

I need to model a measurement of an "exponential decay" i.e. I have a histogram of counts $Y$ over an array of (time-) intervalls. I want to use MCMC to infer parameters ($A_1,\lambda_1,A_2,\lambda_2,\...
bebi's user avatar
  • 83
5 votes
1 answer
2k views

Choice of a model for Bayesian Change Point Detection

I am getting my hands dirty with Probabilistic Programming using Bayesian approach to change-point detection. I read a number of tutorials provided with PyMC and reading the book by Cameron Davidson-...
Vladislavs Dovgalecs's user avatar
5 votes
1 answer
548 views

Analyzing output in MCMC

I am using emcee to do inference on some data. I am trying to fit my data to a line of equation $ y = mx + b $. ...
aloha's user avatar
  • 460

1
2 3 4 5 6