Bayesian course - problem set 3 (lecture 4)

Similar documents
Random Walk Metropolis

Chapter 7: Estimation Sections

Chapter 7: Estimation Sections

CS 361: Probability & Statistics

This is a open-book exam. Assigned: Friday November 27th 2009 at 16:00. Due: Monday November 30th 2009 before 10:00.

Binomial Distributions

Version A. Problem 1. Let X be the continuous random variable defined by the following pdf: 1 x/2 when 0 x 2, f(x) = 0 otherwise.

SOCIETY OF ACTUARIES EXAM STAM SHORT-TERM ACTUARIAL MATHEMATICS EXAM STAM SAMPLE QUESTIONS

Two hours UNIVERSITY OF MANCHESTER. 23 May :00 16:00. Answer ALL SIX questions The total number of marks in the paper is 90.

COS 513: Gibbs Sampling

Review for Final Exam Spring 2014 Jeremy Orloff and Jonathan Bloom

Mathematics of Finance Final Preparation December 19. To be thoroughly prepared for the final exam, you should

Chapter 7: Estimation Sections

Outline. Review Continuation of exercises from last time

Chapter 5. Sampling Distributions

Intro to GLM Day 2: GLM and Maximum Likelihood

TOPIC: PROBABILITY DISTRIBUTIONS

Math489/889 Stochastic Processes and Advanced Mathematical Finance Homework 5

Section M Discrete Probability Distribution

CS 237: Probability in Computing

Actuarial Mathematics and Statistics Statistics 5 Part 2: Statistical Inference Tutorial Problems

CS340 Machine learning Bayesian statistics 3

(Practice Version) Midterm Exam 1

Simple Random Sample

Lecture Slides. Elementary Statistics Tenth Edition. by Mario F. Triola. and the Triola Statistics Series

Actuarial Society of India EXAMINATIONS

Individual Claims Reserving with Stan

Adaptive Experiments for Policy Choice. March 8, 2019

Statistics 6 th Edition

Model 0: We start with a linear regression model: log Y t = β 0 + β 1 (t 1980) + ε, with ε N(0,

EXERCISES FOR PRACTICE SESSION 2 OF STAT CAMP

ECON 214 Elements of Statistics for Economists 2016/2017

II - Probability. Counting Techniques. three rules of counting. 1multiplication rules. 2permutations. 3combinations

Bayesian Normal Stuff

Lecture Notes 6. Assume F belongs to a family of distributions, (e.g. F is Normal), indexed by some parameter θ.

Extracting Information from the Markets: A Bayesian Approach

Review. What is the probability of throwing two 6s in a row with a fair die? a) b) c) d) 0.333

ECON5160: The compulsory term paper

MAKING SENSE OF DATA Essentials series

CS340 Machine learning Bayesian model selection

Conjugate Models. Patrick Lam

Econ 6900: Statistical Problems. Instructor: Yogesh Uppal

Probability Theory. Probability and Statistics for Data Science CSE594 - Spring 2016

Bayesian Multinomial Model for Ordinal Data

***SECTION 8.1*** The Binomial Distributions

Subject CS1 Actuarial Statistics 1 Core Principles. Syllabus. for the 2019 exams. 1 June 2018

Computer Vision Group Prof. Daniel Cremers. 7. Sequential Data

Statistical Methods in Practice STAT/MATH 3379

Getting started with WinBUGS

Extend the ideas of Kan and Zhou paper on Optimal Portfolio Construction under parameter uncertainty

Chapter 4 Probability Distributions

Lecture 17: More on Markov Decision Processes. Reinforcement learning

Stochastic Games and Bayesian Games

Tests for Two ROC Curves

6.825 Homework 3: Solutions

Chapter 8. Variables. Copyright 2004 Brooks/Cole, a division of Thomson Learning, Inc.

TABLE OF CONTENTS - VOLUME 2

STAT 201 Chapter 6. Distribution

Maximum Likelihood Estimation

Stochastic Loss Reserving with Bayesian MCMC Models Revised March 31

Business Statistics 41000: Probability 4

ST440/550: Applied Bayesian Analysis. (5) Multi-parameter models - Summarizing the posterior

Part 1 In which we meet the law of averages. The Law of Averages. The Expected Value & The Standard Error. Where Are We Going?

Exam 2 Spring 2015 Statistics for Applications 4/9/2015

STA 220H1F LEC0201. Week 7: More Probability: Discrete Random Variables

MATH 10 INTRODUCTORY STATISTICS

Probability Distributions. Definitions Discrete vs. Continuous Mean and Standard Deviation TI 83/84 Calculator Binomial Distribution

Homework #2 Psychology 101 Spr 03 Prof Colin Camerer

A Practical Implementation of the Gibbs Sampler for Mixture of Distributions: Application to the Determination of Specifications in Food Industry

[D7] PROBABILITY DISTRIBUTION OF OUTSTANDING LIABILITY FROM INDIVIDUAL PAYMENTS DATA Contributed by T S Wright

AP Statistics Ch 8 The Binomial and Geometric Distributions

Lecture 9. Probability Distributions. Outline. Outline

STAT 111 Recitation 2

Exam STAM Practice Exam #1

Chapter 9. Idea of Probability. Randomness and Probability. Basic Practice of Statistics - 3rd Edition. Chapter 9 1. Introducing Probability


1. You are given the following information about a stationary AR(2) model:

Part II: Computation for Bayesian Analyses

SYSM 6304 Risk and Decision Analysis Lecture 2: Fitting Distributions to Data

Lecture 9. Probability Distributions

Homework: Due Wed, Nov 3 rd Chapter 8, # 48a, 55c and 56 (count as 1), 67a

The binomial distribution p314

6.041SC Probabilistic Systems Analysis and Applied Probability, Fall 2013 Transcript Lecture 23

Corso di Identificazione dei Modelli e Analisi dei Dati

Chapter 3 - Lecture 5 The Binomial Probability Distribution

Subject : Computer Science. Paper: Machine Learning. Module: Decision Theory and Bayesian Decision Theory. Module No: CS/ML/10.

value BE.104 Spring Biostatistics: Distribution and the Mean J. L. Sherley

Chapter 2 Uncertainty Analysis and Sampling Techniques

MBF2263 Portfolio Management. Lecture 8: Risk and Return in Capital Markets

Overview. Definitions. Definitions. Graphs. Chapter 4 Probability Distributions. probability distributions

STA 6166 Fall 2007 Web-based Course. Notes 10: Probability Models

Managerial Economics Uncertainty

ECON 214 Elements of Statistics for Economists

Week 2 Quantitative Analysis of Financial Markets Hypothesis Testing and Confidence Intervals

CHAPTER 4 DISCRETE PROBABILITY DISTRIBUTIONS

The Binomial Probability Distribution

UQ, STAT2201, 2017, Lectures 3 and 4 Unit 3 Probability Distributions.

A useful modeling tricks.

The following content is provided under a Creative Commons license. Your support

ECO220Y Sampling Distributions of Sample Statistics: Sample Proportion Readings: Chapter 10, section

Transcription:

Bayesian course - problem set 3 (lecture 4) Ben Lambert November 14, 2016 1 Ticked off Imagine once again that you are investigating the occurrence of Lyme disease in the UK. This is a vector-borne disease caused by bacteria of species Borrelia which is carried by ticks. (The ticks pick up the infection by blood-feeding on animals/humans that are infected with Borrelia.) As such, you decide to estimate the prevalence of this bacteria in ticks you collect from the grasslands and woodlands around Oxford. As previously, you decide to use sample sizes of 100 ticks, out of which you count the number of ticks testing positive for Borrelia. You decide to use a binomial likelihood since you assume that the presence of Borrelia in one tick is independent of that in other ticks. Also because you sample a relatively small area you assume that the presence of Borrelia can be assumed to be identicallydistributed across ticks. Problem 1.1 Suppose you choose a prior to be a Beta(1,1) distribution. Use sampling to estimate the prior predictive distribution. What is the mean of this distribution? Problem 1.2 In a single sample you find that there are 6 ticks that test positive for Borrelia. Assuming a Beta(1,1) prior analytically calculate the posterior distribution. (Hint: by analytically here I mean look up the result on Google/in the lecture notes.) Graph this distribution. Problem 1.3 Generate 100 independent samples from this distribution using your software s inbuilt (pseudo-)random number generator. Graph this distribution. How does it compare to the pdf of the exact posterior? (Hint: in R the command is rbeta ; in Matlab it is betarnd ; in Mathematica it is Random- Variate[BetaDistribution...] ; in Python it is numpy.random.beta.) Problem 1.4 Evaluate the effect of increasing the sample size for your independent sampler on the estimate of the mean of the distribution. (Hint: for each sample you are essentially comparing the sample mean with the true mean of the posterior.) 1

Problem 1.5 Estimate the variance of the posterior using independent sampling for a sample size of 100. How does your sample estimate compare with the exact solution? Problem 1.6 Create a proposal function for this problem that takes as input a current value of θ, along with a step size, and outputs a proposed value. For a proposal distribution here we use a normal distribution centred on the current θ value with a standard deviation (step size) of 0.1. This means you will need to generate a random θ from a normal distribution using your statistical software s inbuilt random number generator. (Hint: the only slight modification you need to make here is to ensure that we don t get θ < 0 or θ > 1 is to use periodic boundary conditions. To do this we use modular arithmetic. In particular we set θ proposed = mod(θ proposed, 1). The command for this in R is x%%1; in Matlab the command is mod(x, 1); in Mathematica it is Mod[x, 1]; in Python it is x%1.) Problem 1.7 Create the accept/reject function of Random Walk Metropolis that accepts as input θ current and θ proposed and outputs the next value of θ. This is done based on a ratio: r = p(x θ proposedp(θ proposed ) p(x θ current p(θ current ) and a uniformly-distributed random number between 0 and 1, which we call a. If r > a then we update our current value of θ current θ proposed ; alternatively we remain at θ current. Problem 1.8 Create a function that is a combined version of the previous two functions; so it takes as input a current value of θ current, generates a proposed θ proposed, and updates θ current in accordance with the Metropolis accept/reject rule. Problem 1.9 Create a full-working Random Walk Metropolis sampler! (Hint: you will need to iterate the last function repeatedly. As such, you will need to decide on a starting position for θ. I would recommend that you use a uniformlydistributed random number between 0 and 1.) Problem 1.10 For a sample size of 100 from your Metropolis sampler compare the sampling distribution to the exact posterior. How does the estimated posterior compare with that obtained via independent sampling using the same sample size? Problem 1.11 Run 1000 iterations, where in each iteration you run a single chain for 100 iterations. Store the results in a 1000 x 100 matrix. For each iterate calculate the sample mean. Graph the resultant distribution of sample means. How does MCMC do at estimating the posterior mean? Problem 1.12 Graph the distribution of the sample mean estimates of the for the second 50 observations of each chain. How does this result compare with that of the previous question? Why is there a difference? (1) 2

Problem 1.13 Decrease the standard deviation (step size) of the proposal distribution to 0.01. For a sample size of 200, how the posterior for a step size of 0.01 compare to that obtained for 0.1? Problem 1.14 Increase the standard deviation (step size) of the proposal distribution to 1. For a sample size of 200, how the posterior for a step size of 1 compare to that obtained for 0.1? Problem 1.15 Suppose we collect data for a number of such samples (each of size 100), and find the following numbers of ticks that test positive for Borrelia: (3,2,8,25). Either calculate the new posterior exactly, or use sampling to estimate it. (Hint: in both cases make sure you include the original sample of 6!) Problem 1.16 Generate samples from the posterior predictive distribution, and use these to test your model. What do these suggest about your model s assumptions? Problem 1.17 A colleague suggests as an alternative you use a Beta-binomial likelihood, instead of the existent Binomial likelihood. This distribution has two uncertain parameters α > 0 and β > 0 (the other parameter is the sample size; n = 100 in this case), where the mean of the distribution is nα α+β Your colleague and you decide to use weakly informative priors of the form: α Gamma(1, 1 8 ) and β Gamma(10, 1). (Here I am assuming the mean of Gamma(a, b) = a b.) Visualise the joint prior in this case. Problem 1.18 For this situation your colleague tells you, there are unfortunately no conjugate priors. As such, three possible solutions (of many) open to you are: 1. you use numerical integration to find the posterior parameters, or 2. use the Random Walk Metropolis-Hastings algorithm, or 3. you transform each of (α, β) so that they lie between < θ <. Why can t you use vanilla Random Walk Metropolis for (α, β) here? Problem 1.19 By using one of the three methods above estimate the joint posterior distribution. Visualise the pdf of the joint posterior. How are α and β correlated here? Problem 1.20 Construct 80% credible intervals for the parameters of the Betabinomial distribution. Problem 1.21 Carry out appropriate posterior predictive checks using the new model. How does it fare? 2 The fairground revisited You again find yourself in a fairground, and where there is a stall offering the chance to win money if you participate in a game. Before you participate you watch a few other plays of the game (by other people in the crowd) to try to determine whether you want to play. 3

Problem 2.1 In the most-boring version of the game, a woman flips a coin and you bet on its outcome. If the coin lands heads-up, you win; if tails, you lose. Based on your knowledge of similar games (and knowledge that the game must be rigged for the woman to make a profit!) you assume that the coin must be biased towards tails. As such you decide to specify a prior θ beta(2, 5). Graph this function, and using your knowledge of the beta distribution determine the mean parameter value specified by this prior. Problem 2.2 You watch the last 10 plays of the game, and the outcome is heads 3/10 times. Assuming a binomial likelihood, create a function that determines the likelihood for a given value of the heads-probability, θ. Hence or otherwise, determine the maximum likelihood estimate of θ. Problem 2.3 Graph the likelihood prior. From the graph approximately determine the MAP θ estimate value. Problem 2.4 By using R s integrate function find the denominator, and hence graph the posterior pdf. Problem 2.5 Use your posterior to determine your fair price for participating in the game, assuming that you win 1 if the coin comes up heads, and zero otherwise. Problem 2.6 (Optional) Another variant of the game is as follows: the woman flips a first coin if it is tails you lose (Y i = 0), and if it is heads you proceed to the next step. In this step, the woman flips another coin ten times, and records the number of heads, Y i, which determine your winnings. Explain why a reasonable choice for the likelihood might be, { (1 θ) + θ(1 φ) 10, if Y i = 0 L(θ, φ Y i ) = θ ( ) 10 Y i φ Y i (1 φ) 10 Yi, if Y i > 0 where θ and φ are the probabilities of the first and second coins falling heads-up, and Y i is the score on the game. Problem 2.7 (Optional) Using the above formula, write down the overall loglikelihood for a series of N observations for Y i = (Y 1, Y 2,..., Y N ). Problem 2.8 (Optional) Using R s optim function determine the maximum likelihood estimate of the parameters for Y i = (3, 0, 4, 2, 1, 2, 0, 0, 5, 1). Hint 1: Since R s optim function does minimisation by default, you will need to put a minus sign in front of the function to maximise it. Problem 2.9 (Very very optional) Determine confidence intervals on your parameter estimates. Hint 1: use the second derivative of the log-likelihood to estimate the Fischer Information matrix, and hence determine the Cramer-Rao lower bound. Hint 2: use Mathematica! 4

Problem 2.10 Assuming uniform priors for both θ and φ create a function in R that calculates the unnormalised posterior (the numerator of Bayes rule). Problem 2.11 By implementing the Metropolis algorithm, estimate the posterior means of each parameter. Hint 1: use a normal proposal distribution. Hint 2: use periodic boundary conditions on each parameter, so that a proposal off one side of the domain maps onto the other side. Problem 2.12 Find the 95% credible intervals for each parameter. Problem 2.13 Using your posterior samples determine the fair price of the game. Hint: find the mean of the posterior predictive distribution. 5