Questions tagged [mcmc]

Markov chain Monte Carlo (MCMC) methods are a class of algorithms for sampling from a probability distribution based on constructing a Markov chain that has the desired distribution as its equilibrium distribution. The state of the chain after a number of steps is then used as a sample of the desired distribution

Source Wikipedia

493 questions
7
votes
3 answers

ideal() in R package pscl not producing repeatable results

I'm working with the pscl package in R and trying to get it to produce testable/reproducible results. I've taken a look at the underlying C code and it appears as though GetRNGstate() and PutRNGstate() are being called in the right places but it…
Adam Hyland
  • 878
  • 1
  • 9
  • 21
6
votes
2 answers

Speed up Metropolis--Hastings in Python

I have some code that samples a posterior distribution using MCMC, specifically Metropolis Hastings. I use scipy to generate random samples: import numpy as np from scipy import stats def get_samples(n): """ Generate and return a randomly…
PyRsquared
  • 6,970
  • 11
  • 50
  • 86
6
votes
2 answers

How does MCMC help bayesian inference?

Literature says that the metropolis-hasting algorithm in MCMC is one of the most important algorithms developed last century and is revolutional. Literature also says that it is such development in MCMC that gave bayesian statistics a second birth.…
Kid_Learning_C
  • 2,605
  • 4
  • 39
  • 71
6
votes
2 answers

Manipulating mcmc.list object in R

I have used JAGS called via rjags to produce the mcmc.list object foldD_samples, which contains trace monitors for a large number of stochastic nodes (>800 nodes). I would now like to use R to compute a fairly complicated, scalar-valued function of…
Jacob Socolar
  • 1,172
  • 1
  • 9
  • 23
6
votes
3 answers

How to define custom distributions in JAGS?

I am using JAGS for simulating some MCMC distributions. I see the support for a sizeable set of distributions. But, I would like to sample out of a specific distribution that is not defiend in JAGS. Does anyone know how to write our own custom…
Jija
  • 995
  • 8
  • 13
6
votes
1 answer

System time for parallel and serial processing

I'm running a Bayesian MCMC probit model, and I'm trying to implement it in parallel. I'm getting confusing results about the performance of my machine when comparing parallel to serial. I don't have a lot of experience doing parallel processing, so…
6
votes
1 answer

Modified BPMF in PyMC3 using `LKJCorr` priors: PositiveDefiniteError using `NUTS`

I previously implemented the original Bayesian Probabilistic Matrix Factorization (BPMF) model in pymc3. See my previous question for reference, data source, and problem setup. Per the answer to that question from @twiecki, I've implemented a…
Mack
  • 2,614
  • 2
  • 21
  • 33
6
votes
1 answer

Bayesian Probabilistic Matrix Factorization (BPMF) with PyMC3: PositiveDefiniteError using `NUTS`

I've implemented the Bayesian Probabilistic Matrix Factorization algorithm using pymc3 in Python. I also implemented it's precursor, Probabilistic Matrix Factorization (PMF). See my previous question for a reference to the data used here. I'm having…
Mack
  • 2,614
  • 2
  • 21
  • 33
6
votes
1 answer

Parallel RJAGS with convergence testing

I'm modifying an existing model using RJAGS. I'd like to run chains in parallel, and occasionally check the Gelman-Rubin convergence diagnostic to see if I need to keep running. The problem is, if I need to resume running based on the diagnostic…
sjc
  • 1,117
  • 3
  • 19
  • 28
6
votes
2 answers

R : function to generate a mixture distribution

I need to generate samples from a mixed distribution 40% samples come from Gaussian(mean=2,sd=8) 20% samples come from Cauchy(location=25,scale=2) 40% samples come from Gaussian(mean = 10, sd=6) To do this, i wrote the following function : dmix…
Raaj
  • 1,180
  • 4
  • 18
  • 36
6
votes
1 answer

Difficulties on pymc3 vs. pymc2 when discrete variables are involved

I'm updating some calculations where I used pymc2 to pymc3 and I'm having some problems with samplers behavior when I have some discrete random variables on my model. As an example, consider the following model using pymc2: import pymc as pm N =…
Rafael S. Calsaverini
  • 13,582
  • 19
  • 75
  • 132
6
votes
2 answers

optimizing simple Common Lisp gibbs sampler program

As an exercise, I rewrote the example program in the blog post Gibbs sampler in various languages (revisited) by Darren Wilkinson. The code appears below. This code runs on my (5 year old) machine in around 53 seconds, using SBCL 1.0.56, creating a…
Faheem Mitha
  • 6,096
  • 7
  • 48
  • 83
5
votes
2 answers

How do I extract random effects from MCMCglmm?

I am looking for a command similar to ranef() used in nlme, lme4, and brms that will allow me to extract the individual random effects in my MCMCglmm model. In my dataset, I have 40 providers and I would like to extract the random effects for each…
b222
  • 966
  • 1
  • 9
  • 19
5
votes
1 answer

sampling a multimensional posterior distribution using MCMC Metropolis-Hastings algo in R

I am quite new in sampling posterior distributions(so therefore Bayesian approach) using a MCMC technique based on Metropolis-Hastings algorithm. I am using the mcmc library in R for this. My distribution is multidimensionnal. In order to check if…
5
votes
1 answer

Posterior probability with pymc

(This question was originally posted on stats.O. I moved it here because it does relate with pymc and more general matters within it: in fact the main aim is to have a better understanding of how pymc works. If any of the moderators believe it not…
rafforaffo
  • 511
  • 2
  • 7
  • 21
1
2
3
32 33