mcmc diagnosticssbfnk.github.io/mfiidd/slides/mcmc_slides2.pdf · adaptive mcmc adaptive mcmcalters...

12
MCMC Diagnostics

Upload: others

Post on 17-Aug-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: MCMC Diagnosticssbfnk.github.io/mfiidd/slides/mcmc_slides2.pdf · Adaptive MCMC Adaptive MCMCalters proposal distribution while chain is running. Start with large symmetric variance,

MCMC Diagnostics

Page 2: MCMC Diagnosticssbfnk.github.io/mfiidd/slides/mcmc_slides2.pdf · Adaptive MCMC Adaptive MCMCalters proposal distribution while chain is running. Start with large symmetric variance,

Review

In the practical you used Metropolis-Hastings with a Gaussianproposal distribution to infer one parameter, R0

In this session we will:

• extend to multivariate inference

• learn about MCMC diagnostics

• think about accuracy and efficiency

Page 3: MCMC Diagnosticssbfnk.github.io/mfiidd/slides/mcmc_slides2.pdf · Adaptive MCMC Adaptive MCMCalters proposal distribution while chain is running. Start with large symmetric variance,

Interlude: Multivariate Gaussian distribution

To infer more multiple parameters we can use multivariate Gaussian

mean µ =[3 2

]covariance Σ =

[25 00 9

] mean µ =[3 2

]covariance Σ =

[10 55 5

]

For accurate and efficient MCMC we tune the variance andcovariance of the proposal distribution.

Page 4: MCMC Diagnosticssbfnk.github.io/mfiidd/slides/mcmc_slides2.pdf · Adaptive MCMC Adaptive MCMCalters proposal distribution while chain is running. Start with large symmetric variance,

Why I like hairy caterpillars

Key characterisitics

• Straight

• Plump head, plump rear!

• Multiple colours

Page 5: MCMC Diagnosticssbfnk.github.io/mfiidd/slides/mcmc_slides2.pdf · Adaptive MCMC Adaptive MCMCalters proposal distribution while chain is running. Start with large symmetric variance,

Choosing a proposal distribution

If variance is too small, the chain will be slow to reach the targetdistribution.

Page 6: MCMC Diagnosticssbfnk.github.io/mfiidd/slides/mcmc_slides2.pdf · Adaptive MCMC Adaptive MCMCalters proposal distribution while chain is running. Start with large symmetric variance,

Choosing a proposal distribution

If variance is too high, many proposed values will be rejected andthe chain will stick in one place for many steps.

Page 7: MCMC Diagnosticssbfnk.github.io/mfiidd/slides/mcmc_slides2.pdf · Adaptive MCMC Adaptive MCMCalters proposal distribution while chain is running. Start with large symmetric variance,

Choosing a proposal distribution

If variance is just right, the chain will efficiently explore the fullshape of the target distribution.

Try several different proposal distributions (pilot runs), aiming foran acceptance rate between 24% and 40%.

Page 8: MCMC Diagnosticssbfnk.github.io/mfiidd/slides/mcmc_slides2.pdf · Adaptive MCMC Adaptive MCMCalters proposal distribution while chain is running. Start with large symmetric variance,

Adaptive MCMC

• Adaptive MCMC alters proposal distribution while chain isrunning.

• Start with large symmetric variance, scan around to find amode.

• Then alter shape of proposal distribution to match covariancematrix of accepted values.

• Eventually proposal density should match the shape of targetdensity.

Page 9: MCMC Diagnosticssbfnk.github.io/mfiidd/slides/mcmc_slides2.pdf · Adaptive MCMC Adaptive MCMCalters proposal distribution while chain is running. Start with large symmetric variance,

Adaptive MCMC

Two-stage adaptation

Page 10: MCMC Diagnosticssbfnk.github.io/mfiidd/slides/mcmc_slides2.pdf · Adaptive MCMC Adaptive MCMCalters proposal distribution while chain is running. Start with large symmetric variance,

Burn-in

• We can start our MCMC chainanywhere.

• It can take a while to reach andexplore the target density f (θ).

• Throw away early samples: burn-inphase.

• How much to discard?

Lepidoptera caterpillar

Page 11: MCMC Diagnosticssbfnk.github.io/mfiidd/slides/mcmc_slides2.pdf · Adaptive MCMC Adaptive MCMCalters proposal distribution while chain is running. Start with large symmetric variance,

MCMC sample size

• In MCMC, each sample depends on the one before -auto-correlation

• Reduce degree of auto-correlation by thinning, only retainevery nth sample.

• Information content of MCMC samples is given by theeffective sample size (ESS).

• We use the R package coda.

Page 12: MCMC Diagnosticssbfnk.github.io/mfiidd/slides/mcmc_slides2.pdf · Adaptive MCMC Adaptive MCMCalters proposal distribution while chain is running. Start with large symmetric variance,

Accuracy and efficiency

How does each element influence accuracy and efficiency?

• Burn-in

• MCMC iterations (after burn-in)

• Thinning

• Number of chains (with different initial conditions)

• Proposal distribution

• Transforming parameters