mcmc - \documentclass[11pt]cfw_article...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
\documentclass[11pt]{article} \usepackage{graphics} \usepackage{amsmath} \usepackage{indentfirst} % \usepackage[utf8]{inputenc} \usepackage{url} \DeclareMathOperator{\sd}{sd} \DeclareMathOperator{\var}{var} \DeclareMathOperator{\cov}{cov} \DeclareMathOperator{\trigamma}{trigamma} \DeclareMathOperator{\NormalDis}{\mathcal{N}} \DeclareMathOperator{\UniformDis}{Unif} \newcommand{\boldtheta}{\boldsymbol{\theta}} \newcommand{\boldI}{\mathbf{I}} \newcommand{\boldM}{\mathbf{M}} \newcommand{\boldX}{\mathbf{X}} \newcommand{\boldY}{\mathbf{Y}} \newcommand{\weakto}{\stackrel{\mathcal{D}}{\longrightarrow}} \begin{document} <<foo,include=FALSE,echo=FALSE>>= options(keep.source = TRUE, width = 60) @ \title{Stat 5102 Notes: Markov Chain Monte Carlo and Bayesian Inference} \author{Charles J. Geyer} \maketitle \section{The Problem} This is an example of an application of Bayes rule that requires some form of computer analysis. We will use Markov chain Monte Carlo (MCMC). The problem is the same one that was done by maximum likelihood on the computer examples web pages (\url{}). The data model is gamma. We will use the Jeffreys prior. \subsection{Data} The data are loaded by the R command <<data>>= foo <- read.table(url(""), header = TRUE) x <- foo$x @ \subsection{R Package} We load the R contributed package \texttt{mcmc}, which is available from CRAN. <<library>>= library(mcmc) @
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
If this does not work, then get the library using the package menu for R. \subsection{Random Number Generator Seed} In order to get the same results every time, we set the seed of the random number generator. <<library>>= set.seed(42) @ To get different results, change the seed or simply omit this statement. \subsection{Prior} We have not done the Fisher information matrix for the two-parameter gamma distribution. To calculate Fisher information, it is enough to have the log likelihood for sample size one. The PDF is $$ f(x \mid \alpha, \lambda) = \frac{\lambda^\alpha}{\Gamma(\alpha)} x^{\alpha - 1} \exp\left( - \lambda x \right) $$ The log likelihood is $$ l(\alpha, \lambda) = \log f(x \mid \alpha, \lambda) = \alpha \log(\lambda) - \log \Gamma(\alpha) + (\alpha - 1) \log(x) - \lambda x $$ which has derivatives \begin{align*} \frac{\partial l(\alpha, \lambda)}{\partial \alpha} \log(\lambda) - \frac{d}{d \alpha} \log \Gamma(\alpha) + \log(x) \\ \frac{\partial l(\alpha, \lambda)}{\partial \lambda} \frac{\alpha}{\lambda} - x \\ \frac{\partial^2 l(\alpha, \lambda)}{\partial \alpha^2} & = - \frac{d^2}{d \alpha^2} \log \Gamma(\alpha) \\ \frac{\partial^2 l(\alpha, \lambda)}{\partial \alpha \partial \lambda} \frac{1}{\lambda} \\ \frac{\partial^2 l(\alpha, \lambda)}{\partial \lambda^2} & = - \frac{\alpha}{\lambda^2} \end{align*} % foo = alpha Log[lambda] - Log[Gamma[alpha]] + (alpha - 1) Log[x] - lambda x % D[ D[ foo, alpha ], alpha ] % D[ D[ foo, alpha ], lambda ] % D[ D[ foo, lambda ], lambda ]
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/28/2010 for the course STAT 2102 taught by Professor Geyer during the Spring '09 term at Minnesota.

Page1 / 11

mcmc - \documentclass[11pt]cfw_article...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online