11.07.2015 Views

statisticalrethinkin..

statisticalrethinkin..

statisticalrethinkin..

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

256 8. MARKOV CHAIN MONTE CARLO ESTIMATIONmu ~ a + br * rugged + bA * cont_africa + brA * rugged * cont_africaa ~ dnorm(0, 100)br ~ dnorm(0, 10)bA ~ dnorm(0, 10)brA ~ dnorm(0, 10)sigma ~ dcauchy(0, 1)Log-likelihood at expected values: -229.43Deviance: 458.86DIC: 468.66Effective number of parameters (pD): 4.9is report just reiterates the formulas used to define the Markov chain and then reportslog-likelihood, deviance, DIC, and the effective number of parameters p D (as estimated incomputing DIC).8.3.5. Checking the chain. Provided the Markov chain is defined correctly—and it is here—then it is guaranteed to converge in the long run to the answer we want, the posterior distribution.But the machine does sometimes malfunction. In the next major section, we’ll dwellon causes of and solutions to malfunction.For now, let’s meet the most broadly useful tool for diagnosing malfunction, a TRACEPLOT. A trace plot merely plots the samples in sequential order, joined by a line. Looking atthe trace of each parameter in this way can quickly diagnose many common problems. Andonce you come to recognize a healthy, functioning Markov chain, quick checks of trace plotsprovide a lot of peace of mind. A trace plot isn’t the last thing analysts do to inspect MCMCoutput. But it’s nearly always the first.In the ruggedness example, the trace plot shows a very healthy chain. View it with:R code8.10plotchains(m8.1stan)e result is shown in FIGURE 8.6. Each plot in this figure is similar to what you’d get ifyou just used, for example, plot(post$a,type="l"), but with some extra information andlabeling to help out. You can think of the zig-zagging trace of each parameter as the paththe chain took through each dimension of parameter space. It’s easier to see this path inthe zoomed plot in the lower right corner, which displays only the first 100 samples aerwarmup.e gray region in each plot, the first one-thousand samples, marks the adaptation samples.During adaptation, the Markov chain is learning to more efficiently sample from theposterior distribution. So these samples are not necessarily reliable to use for inference. eyare automatically discarded by extract.samples, which returns only the samples shownin the white regions of FIGURE 8.6.Now, how is this chain a healthy one? Typically we look for two things in these traceplots: stationarity and good mixing. Stationarity refers to the path staying within the posteriordistribution. Notice that these traces, for example, all stick around a very stable centraltendency, the center of gravity of each dimension of the posterior. Another way to think ofthis is that the mean value of the chain is quite stable from beginning to end.A well-mixing chain means that each successive sample within each parameter is nothighly correlated with the sample before it. Visually, you can see this by the rapid zig-zag

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!