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
0
votes
1 answer

pymc3 multinomial mixture gets stuck

I am trying use PYMC3 to implement an example where the data comes from a mixture of multinomials. The goal is to infer the underlying state_prob vector (see below). The code runs, but the Metropolis sampler gets stuck at the initial state_prior…
Antony Joseph
  • 255
  • 2
  • 7
0
votes
2 answers

How to plot a probability distribution with `pymc.MCMC` in Python

I know that I can use: S = pymc.MCMC(model1) from pymc import Matplot as mcplt mcplt.plot(S) and that will give me a figure with three plots but all I want is just a single plot of the histogram. Then I want to normalise the histogram and then make…
MRT
  • 793
  • 7
  • 12
0
votes
0 answers

Using an ordered bayesian probit - how to calculate Bayesfactor?

I'm trying to find the bayesfactor for three models which I've run (code below). library(Zelig) DV1.1 <- zelig(as.factor(DV1) ~ IV1, model = "oprobit.bayes", mcmc=500000, data = DataCL) DV1.2 <- zelig(as.factor(DV1) ~ IV1 + IV2, model =…
Isobel
  • 41
  • 1
  • 3
0
votes
1 answer

Combining lists into a dataframe more efficiently

I am running multiple chains of a MCMCglmm() model and I am trying to find the most efficient way to synthesize my output. I am using mclapply() to run 4 chains and then combining each of the 4 chains into a list with lapply(). Here is my model…
b222
  • 966
  • 1
  • 9
  • 19
0
votes
1 answer

Get the expectation of random variables function's distribution by sampling from the joint distribution

I am not professional in Probability & Statisticsin, in order to clearly describe my problem, please be patient of the long introduction.THANKS! Background of my question Assume I have several independent random variables, say X and Y, and their…
Mike
  • 35
  • 5
0
votes
0 answers

Random seed for reproducibility for MCMC sampler in pymc

I have constructed a hierarchical model (in pymc) with 5 stochastic variables and a single deterministic variable and I want to be able to set a random seed so that the sampler is able to reproduce identical traces. I've tried various things like…
KSR
  • 1
0
votes
1 answer

TypeError: logistic() missing 1 required positional argument: 'params'

I'm tasked with fitting the model of ODE equations to data using MCMC but can't get past the error: TypeError Traceback (most recent call last) in () 26 proposed[j] =…
Matthew Freeman
  • 3
  • 1
  • 2
  • 7
0
votes
1 answer

constrained random numbers sampling using python (Monte-Carlo, Markov chains, pymc)

I am trying to sample random numbers with constraints using Python and pymc library. Here mins and maxes are arrays of minimums and maximums for each of 22 variables. It works fine in this case. from pymc import * X = Uniform('X', mins,…
dark980
  • 21
  • 4
0
votes
1 answer

How to especify stronger priors in MCMCglmm?

I have been working for weeks with the MCMCglmm R package. It's the first time I work with it. I have read a lot of papers and guides for a better understanding but I can't solve the problem that I have: That's a piece of my data (just for one…
0
votes
0 answers

MCMC - when MCMC should be used and standard MC methods are difficult

I have not be able to find clear answers to the following two questions regarding MCMC: If I were to evaluate the expected value (more generally, expected value of a function) of a target distribution using MCMC, my first thought of the procedure…
0
votes
3 answers

What are alternatives to `if` statements to improve performance of MCMC algorithms?

I am running a MCMC algorithm with Metropolis Hastings step in R, which requires accepting or rejecting a proposal sample according to a logical rule. Currently, I have implemented this as if(sample meets condition){accept} else{reject} I heard…
tomka
  • 2,516
  • 7
  • 31
  • 45
0
votes
1 answer

Walkers in emcee not exploring parameter space?

First of all: apologies for the lack of code and rather vague descriptions; the code I'm using is 1000+ lines long and I'm not sure what parts of it would be helpful to post. I'm using emcee to do some Bayesian parameter estimation. My code uses 50…
rrose
  • 69
  • 1
  • 4
0
votes
1 answer

MCMC in R Modify Proposal

I've been working with MCMC for population genetics and I have some doubts. I'm not experienced in statistics and because of that I have difficulty. I have code to run MCMC, 1000 iterations. I start by creating a matrix with 0's (50 columns = 50…
Targaryel
  • 117
  • 1
  • 8
0
votes
0 answers

Sampling a Boltzmann Distribution using Python's emcee

I'm a beginner at python and am learning to use MCMC sampling methods, using python's emcee package. As a beginner exercise I want to sample a Maxwell-Boltzmann Distribution. I have an example code which samples a Gaussian, defined through the…
0
votes
1 answer

Reconstructing variables from mcmc objects

I am using rjags as a sampler. The model has 3 matrices defined. The coda.samples function returns a list of samples. If I take the first sample list the column names look something like this: > colnames(output[[1]]) "A[1,1]" "A[2,1]" "A[1,2]" …
Davor Josipovic
  • 5,296
  • 1
  • 39
  • 57