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

PyMC code gives unusual results

I tried to solve a logistic regression model using PyMC. However, the diagnostic plots show very high autocorrelations and after repeated sampling from the posterior distribution, I sometimes obtain very different results, so maybe I'm not using…
r_31415
  • 8,752
  • 17
  • 74
  • 121
0
votes
1 answer

Defining the exponential prior with jumping order of magnitude in parameter space

I want to define an Exponential prior for a parameter as following Therefore I have defined it in pymc with @pm.stochastic def MASS(value=math.pow(10,15), rate = math.pow(10,15)): """mass is a stochastic parameter with exponential…
Dalek
  • 4,168
  • 11
  • 48
  • 100
0
votes
1 answer

Defining priors and marginalizing over priors in pymc

I am going through the tutorial about Monte Carlo Markov Chain process with pymc library. I am also a newbie using pymc and try to establish my own MCMC process. I have faced couple of question that I couldn't find proper answer in pymc…
Dalek
  • 4,168
  • 11
  • 48
  • 100
0
votes
1 answer

TypeError: hasattr(): attribute name must be string in pymc

I have looked at the following links but none of them provide the solution I am looking for https://github.com/pymc-devs/pymc/issues/125 PyMC error : hasattr(): attribute name must be string I have to write a function which given the priors (and…
turing
  • 577
  • 1
  • 4
  • 12
0
votes
1 answer

Two execution of MAP in pymc gives different values

I wanted to learn about MAP optimization im pymc. I got the following posterior distribution of lambda after sampling using mcmc Clearly, the posterior is maximum at lambda = 0.20 and the 95% intervals are [0.17, 0.24] (please correct me if I am…
turing
  • 577
  • 1
  • 4
  • 12
0
votes
1 answer

KeyError while printing trace in PyMC

I had read that by default some names are assigned to Stochastic vaiables. I am writing the relevant portion of my code below. lam = pm.Uniform('lam', lower=0.0, upper=5, doc='lam') parameters = pm.Dirichlet('parameters',[1,1,1,1],…
turing
  • 577
  • 1
  • 4
  • 12
0
votes
1 answer

MAP in PyMC is giving unexpected error

I don't understand why MAP is giving error where as MCMC works fine in the same scenario? I am writing below the relevant part of code. tau = Uniform('tau', lower=0.01, upper=5, doc='tau') rv = [ Multinomial("rv"+str(i), count[i],…
turing
  • 577
  • 1
  • 4
  • 12
0
votes
1 answer

Octave approximation of e

I want to use MCMC algorithm in Octave to calculate with max precision the following expression: "1/e". After reading some tutorials I found a formula for calculating π, but I do not understand how it works. octave:2> S=1e7; a=rand(S,2);…
Steffi
  • 867
  • 5
  • 14
  • 29
0
votes
1 answer

Meaning of a variable declaration in PyMC

In this tutorial http://pymc-devs.github.io/pymc/tutorial.html#an-example-statistical-model , disasters = Poisson('disasters', mu=rate, value=disasters_array, observed=True) this line denotes that disasters is a poisson random variable or disasters…
turing
  • 577
  • 1
  • 4
  • 12
0
votes
1 answer

Metropolis Hastings with Custom Log likelihood in Pymc

I want to use pymc to use a MH chain to sample from a custom log likelihood. But I can't seem to get it to work and can't find a decent example online. def getPymcVariable(data): def logp(value): ... return ljps # returns a float def…
tetradeca7tope
  • 491
  • 1
  • 5
  • 7
0
votes
2 answers

PyMC: sampling step by step?

I would like to know why the sampler is incredibly slow when sampling step by step. For example, if I run: mcmc = MCMC(model) mcmc.sample(1000) the sampling is fast. However, if I run: mcmc = MCMC(model) for i in arange(1000): …
p.paolo321
  • 193
  • 1
  • 1
  • 7
0
votes
1 answer

Regression with “unidirectional” noise

I would like to estimate the parameters of a simple linear function and a gamma-distributed noise term from data. (Note: This is a follow-up question of https://stats.stackexchange.com/questions/88676/regression-with-unidirectional-noise, but…
frisbee
  • 73
  • 1
  • 6
0
votes
0 answers

How to speed up the rjags model training in Bayesian ranking?

All, I am doing Bayesian modeling using rjags. However, when the number of observation is larger than 1000. The graph size is too big. More specifically, I am doing a Bayesian ranking problem. Traditionally, one observation means one X[i,…
Jack Fu
  • 43
  • 1
  • 7
0
votes
1 answer

How to find probability of posterior parameter with Winbugs

My winbugs code is as follows: model { for ( i in 1:N){ logit(p[i])<- alpha+ beta*x[i] y[i]~ dbin(p[i], n[i]) } alpha~ dnorm(0,0.000001) beta~ dnorm(0,0.000001) pbeta<-step(beta-0) } list(N=20, n=c(6, 7, 6, 8, 8, 5, 6,…
Thaole
  • 9
  • 4
0
votes
1 answer

PyMC regression of many regressions?

I haven't been using PyMC for long, but I was pleased at how quickly I was able to get a linear regression off the ground (this code should run without modification in IPython): import pandas as pd from numpy import * import…
agartland
  • 1,654
  • 2
  • 15
  • 19
1 2 3
32
33