snowdrop.src.numeric.bayes package¶
Submodules¶
snowdrop.src.numeric.bayes.mcmc module¶
Created on Fri Apr 5 13:09:34 2019
Curently implemented for linear models only.
@author: A.Goumilevski
- snowdrop.src.numeric.bayes.mcmc.func_likelihood(p, *args)[source]¶
Custom function defining log of likelihood.
- snowdrop.src.numeric.bayes.mcmc.func_prior(p, *args)[source]¶
Custom function defining log of prior probability.
- snowdrop.src.numeric.bayes.mcmc.likelihood_logp(parameters, stds)[source]¶
Function defining log of likelihood.
- snowdrop.src.numeric.bayes.mcmc.logp(p, *args)[source]¶
Custom function defining log of posterioir probability.
- snowdrop.src.numeric.bayes.mcmc.sample(model, n, obs, Qm, Hm, y0, method='emcee', parameters=None, steady_state=None, burn=10, Ndraws=310, Niter=200, ind_non_missing=None, Parallel=False, resetParameters=True, debug=True, save=False)[source]¶
Draw model parameters samples by using MCMC sampler.
The variants of MC2 sampler are:
- Affine Invariant Markov Chain Monte Carlo (MCMC) Ensemble sampler (emcee package).
Emcee is a Python ensemble sampling toolkit for affine-invariant MCMC.
For references on emcee package please see http://dfm.io/emcee/current/
The algorithm is based on 2010 paper of Jonathan Goodman and Jonathan Weare’s paper, “Ensemble Samplers with Affine Invariance”, https://projecteuclid.org/download/pdf_1/euclid.camcos/1513731992
- Markov Chain Monte Carlo (MCMC) sampler includes different Metropolis based sampling techniques:
Metropolis-Hastings (MH): Primary sampling method.
Adaptive-Metropolis (AM): Adapts covariance matrix at specified intervals.
Delayed-Rejection (DR): Delays rejection by sampling from a narrower distribution. Capable of n-stage delayed rejection.
Delayed Rejection Adaptive Metropolis (DRAM): DR + AM
Please see https://pymcmcstat.readthedocs.io/_/downloads/en/latest/pdf/
- Markov Chain Monte Carlo (MCMC) sampler with “particles” package
Please see https://pypi.org/project/particles , https://github.com/nchopin/particles ,
Nicolas, Chopin and Omiros, Papaspiliopoulos, 2020, “An Introduction to Sequential Monte Carlo”, Springer Series in Statistics.
- Parameters:
- param model:
Model object.
- type model:
Model.
- param n:
Number of endogenous variables.
- type n:
int.
- param obs:
Measurement data.
- type obs:
numpy.array.
- param Qm:
Covariance matrix of errors of endogenous variables.
- type Qm:
numpy.array.
- param Hm:
Covariance matrix of errors of measurement variables.
- type Hm:
numpy.array.
- param y0:
Starting values of endogenous variables.
- type y0:
list.
- param method:
Sampler algorithm.
- type method:
str.
- param parameters:
List of model parameters.
- type parameters:
list.
- param steady_state:
List of steady states.
- type steady_state:
list.
- param burn:
Number of samples to discard.
- type burn:
int.
- param Ndraws:
Number of draws.
- type Ndraws:
int.
- param Niter:
Number of iterations.
- type Niter:
int.
- param ind_non_missing:
indices of non-missing observations.
- type ind_non_missing:
list.
- param Parallel:
If True runs parallel parameters sampling.
- type Parallel:
bool.
- param resetParameters:
If True resets parameters to the samples mean values.
- type resetParameters:
bool
- param debug:
If True print chain statistics information for pymcmcstat method.
- type debug:
bool.