Popular in Course
Popular in Statistics
This 12 page Class Notes was uploaded by Orval Funk on Monday September 28, 2015. The Class Notes belongs to STAT512 at University of Pennsylvania taught by Staff in Fall. Since its upload, it has received 11 views. For similar materials see /class/215440/stat512-university-of-pennsylvania in Statistics at University of Pennsylvania.
Reviews for MATHEMATICALSTATISTICS
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 09/28/15
Statistics 512 Notes 9 The Monte Carlo Method Continued The Monte Carlo method Consider a function g of a random vector X where X has density f Consider the expected value of g Eg I g1f d Suppose we take an iid random samples XV 7 Km from the density fCX Then by the law of large numbers m X P 1 gtEg The Monte Carlo method is to do a simulation to draw Klan7X from the density f and estimate Egl A Xi by Egf In a simulation we can make m as large as we want Standard error of the estimate is m 2 leg1m SEA gar 1 m By the Central Limit Theorem an approximate 95 con dence interval for Egl is Eg i1965 09 Example Monte Carlo estimation of 7r De ne the unit square as a square centered at 0505 with sides of length l and the unit circle as the circle centered at the origin with a radius of length l The ratio of the area of the unit circle that lies in the rst quadrant to the area of the unit square is 71 4 Let U1 and U2 be iid uniform 01 random variables Let gU17U2l if UlaUZ is in the unit circle and 0 7 otherwise Then EgU1gtU2 Z Monte Carlo method Repeat the experiment of drawing X U17U2 U1 and U2 iid uniform 01 random variables m times and estimate 7T by A Ef gw iz 77 4 m An approximate 95 con dence interval for 7Zis 2 m aUz39 ZzlgUleU12Zlnllz A 7Z39l96 4 m 1 Because 8U17U20 or 1 l is equivalent to il964 1 m In R the command runifn draws n iid uniform O 1 random variables Here is a function for estimating pi piestfunctionm Obtains the estimate of pi and its standard error for the simulation discussed in Example 581 n is the number of simulations Draw ul u2 iid uniform 01 random variables u1runifm u2runifm cntrep0m chkVector which checks if u1u2 is in the unit circle chku1A2u2A21 cnti1 if u1u2 is in unit circle cntchklt01 Estimate of pi est4meancnt Lower and upper con dence interval endpoints lciest 4meancntlmeancntmquot5 uciest4meancntlmeancntm 5 listestimateestlcilciuciuci gt piest100000 estimate 1 313912 lci 1 3133922 uci 1 3144318 Back to Example 585 The true size of the 005 nominal size ttest for random samples of size 20 contaminated normal distribution A We want to estimate EIlx1x20 gt 1 729 Monte Carlo method Zlltxi1 x120 gt 1729 m EIlx1x20 gt1729 where XI1 X220 is a random sample of size 20 from the contaminated normal distribution A Here X X1gtgtX20 and fis the density ofa random sample of size 20 from the contaminated normal distribution A and g ZX17 397X20gt1 729 How to draw a random observation from the contaminated normal distribution A 1 Draw a Bernoulli random variable B with p025 2 If BO draw a random observation from the standard normal distribution If Bl draw a random observation from the normal distribution with mean 0 and standard deviation 25 In R the command mormnmean0sdl draws a random sample of size n from the normal distribution with the speci ed mean and SD The command rbinomnsizelp draws a random sample of size n from Bernoulli distribution with probability of success p R function for obtaining Monte Carlo estimate EIlx1x20 gt 1 729 empalphacnfunctionnsims Obtains the empirical level of the test discussed in Example 585 nsims is the number of simulations sigmac25 SD when observation is contaminated probcont25 Probability of contamination alpha05 Signi cance level for ttest n20 Sample size tcqtlalphanl Critical value for ttest ic0 ic will count the number of times ttest is rejected fori in lnsims Bernoulli random variable which determines whether each observation in sample is from standard normal or normal with SD sigmac brbinomnsizelprobprobcont Sample observations from standard normal when b0 and normal with SD sigmac when bl sampmormnmean0sdlb24 Calculate tstatistics for testing mu0 based on sample tstatmeansampvarsampquot5n 5 Check if we reject the null hypothesis for the ttest iftstatgttc icicl Estimated true signi cance level equals proportion of rejections empalpicnsims Standard error for estimate of true signi cance level sel 96empalpl empalpnsimsquot 5 lciempalpl 96se uciempalpl 96se listempiricalalphaempalplcilciuciuci gt empalphacnlOOOOO empiricalalpha 1 004086 lci 1 003845507 uci 1 004326493 Based on these results the nominal 005 size ttest appears to be slightly conservative when a sample of size 20 is drawn from this contaminated normal distribution Generating random observations with given cdf F Theorem 581 Suppose the random variable U has a uniform O 1 distribution Let F be the cdf of a random variable that is strictly increasing on some interval 1 where FO to the left of I and F1 to the right of I Then the random variable X I F71U has cdf F where F 101eft endpoint of I and F 711 right endpoint of 1 Proof A uniform distribution on O 1 has the CDF FU u u for u E 071 Using the fact that the CDF F is a strictly monotone increasing function on the interval 1 then on PX g x PF 1U g x PFF U Fx PU g F x Fx Dif cult to use this method when simulating random variables whose inverse CDF cannot be obtained in closed form Other methods for simulating a random variable 1 AcceptReject Algorithm Chapter 581 2 Markov chain Monte Carlo Methods Chapter 114 R commands for generating random variables runif uniform random variables rbinom binomial random variables rnorrn normal random variables rt t random variables rpois Poisson random variables reXp exponential random variables rgamma gamma random variables rbeta beta random variables rcauchy Cauchy random variables rchisq chisquared random variables rF F random variables rgeom geometric random variables rnbinom negative binomial random variables Bootstrap Procedures Bootstrap standard errors X1Xniid with CDF F and variance 0392 2 Var M izVarXlXna n n n i J s We estimate SD00 by SEX Ewhere S is the 500 2 sample standard deviation What about SDiMedianXp Xn This SD depends in a complicated way on the distribution F of the X s How to approximate it Real World FgtX1 Xn 3T MedianX1gt39 gtXn The bootstrap principle is to approximate the real world by assuming that F I anhere F is the empirical CDF ie l the distribution that puts Z probability on each of X1Xn We simulate from F by drawing one point at random from the original data set Bootstrap World 13 3 XfX 3 7 MedianXfX The bootstrap estimate of SDMedianX1 Xn is SDiMedianX7 X where Xgtquot39gtX are iid draws from n How to approximate SDMedicmX 1 7 7 X The Monte Carlo method 1 m 1 m 2 E2i1gAXiZilgXij iZ ngfiZf ngfojzi EgX2 Eg2 Va goo Bootstrap Standard Error Estimation for Statistic Tn gX1Xn 1 Draw Xgtquot397X 2 Compute T gX1X 3 Repeat steps 1 and 2 m times to get Egan774 l m 1 m 2 4 Let seboot 2 Zr1Tm The bootstrap involves two approximations not so small approx error small approx error SDF z z sebool R function for bootstrap estimate of SEMedian bootstrapmedianfuncfunctionXbootreps medianXmedianX vector that will store the bootstrapped medians bootmediansrep0bootreps fori in lbootreps Draw a sample of size n from X with replacement and calculate median of sample XstarsampleXsizelengthXreplaceTRUE bootmediansimedianXstar sebootvarbootmediansquot 5 listmedianXmedianXsebootseboot Example In a study of the natural variability of rainfall the rainfall of summer storms was measured by a network of rain gauges in southern Illinois for the year 1960 gtrainfallc02010521003450010121307010 1001003043219181200111240026708003 022901003422700100104011720011429 0020405060811307002 gt medianrainfall 1 0045 gt bootstrapmedianfunc rainfall 10000 medianX 110045 seboot 1 002167736
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'