﻿ STAT代写 Computational Methods代写 algorithm代写 R code代写

# STAT代写 Computational Methods代写 algorithm代写 R code代写

2020-11-26 18:00 星期四 所属： R语言代写 浏览：139 ## STAT4CI3/6CI3 Computational Methods forInference

STAT代写 Please indicate clearly on your solutions whether you are in STATS 4CI3 or STATS 6CI3.Non-code parts of the solutions

Assignment 2 Due at 1:30pm on Monday, February 25, 2019

### Instructions:STAT代写

1. Please indicate clearly on your solutions whether you are in STATS 4CI3 or STATS
2. Non-codeparts of the solutions need not be typed but must be
3. Ensure that all R code is properly commented and attach a print out with your written solution.Also mail your R code as a plain text file to [email protected] using the subject S4CI3 Assignment 1: <Name> <Student ID>
4. Starteach question on a new page and submit questions in the same order as given  It is important to ensure that all parts of a question are together.STAT代写
5. Youare expected to show all details of your solution and any results taken from my notes or elsewhere must be clearly and properly
6. No extensions to the due date and time will be given except in extreme circumstances and late assignments without prior approval will not be
7. Studentsare reminded that submitted assignments must be entirely their own  Submission of all or part of someone else’s solution (including solutions from the internet or othersources) under your name is academic misconduct and will be dealt with as such. Penalties for academic misconduct can include a 0 for the assignment, an F for the course with an annotation on your transcript and/or dismissal from your program of study.
8. Questions4(c) and 5 marked [STAT6CI3] are for the graduate students

#### Q.1 Consider the following rejectionalgorithm STAT代写

1. Generate 2 independent Unif(0, 1) random variables U1and U2.
2. Let X = ln U1and Y = ln U2.
3. If 2X “ (Y 1)2return Y .STAT代写

a)Prove that X and Y are independent exp(1) random

b)Use Bayes Theorem to provethat

f .y.2X “ (Y 1)2Σ  ey2/2 for y > 0.

c)Using a transformation showthat

and hence give the density of the accepted observations.

d)Suppose that Y is generated using this method and U3is another Unif(0, 1) random variable. Define the random variable Z as #### Show that Z is a standard normal random variable.

e)Writean R function which will generate n random standard normal observations using this technique.STAT代写

Q.2  a)Using only Unif(0, 1) random variates, use a Monte Carlo algorithm to approximate the value of the Gamma function by considering the function as an expectation of a function of a random variable.

b)Showthat if a Monte Carlo simulation of size is used then the variance of the Monte Carlo estimator is

provided that α > 0.5.

c)Write an R function to implement the method returning the estimated value of the function and the standard error of the estimation. Examine how well the method worksfor various values of α and various simulation sizes.STAT代写

#### Q.3Suppose that we wish to use Monte Carlo methods to estimate the integral In the following questions write an R function to estimate this quantity based on uniform(0,1)random variates only. Your functions should return both the estimate and the standard errorof the estimate and you should present the estimates and standard errors using N = 100000. Please use your student number to set the random seed (using set.seed) for each part of the question.STAT代写

a)Implement the basic Monte Carlo method by writing I as an expected

b)Implementa control variable estimate using the average of squared uniform(0, 1) ran- dom variables as the control  In your solution you should estimate the best β to use based on the output.

c)Implementan antithetic variable method to estimate I based on a sample of uniform(0, 1) random variables and the fact that if U  uniform(0, 1) then 1  U  uniform(0, 1).STAT代写

d)Implementan importance sampling estimator using a observations from a Beta(α, 1)  Give the value of α you use and describe how you selected that value.

#### Q.4 A large-sample 100(1 − α)% confidence interval for the mean is givenby where x and s are the sample mean and standard deviation respectively and zα/2 is the upper α/2 quantile of the standard normal distribution.  The coverage of the confidence interval is defined to be the probability that the interval contains the true value µ. For the following questions suppose that α = 0.05.

a)Show (analytically) that, for a fixed n, the coverage probability does not dependon µ and σ if the data come from a normal(µ, σ2) distribution. Use a simulation study to estimate the coverage of the interval when the data truly comes from a normal distribution and examine how the coverage changes as the sample size changes. Use your simulation study to say how large a sample would you need to get within one percentage point of the nominal coverage?STAT代写

b)Supposenow that the data comes from an exponential distribution with mean µ. Show that the coverage probability does not depend on µ > Implement a simulation study to examine how the coverage changes with n. Estimate the probability that the confidence interval includes negative values of µ. How large a sample would you need to get within one percentage point of the nominal coverage?

c)[STAT6CI3] Now suppose that the underlying data is log-normal. That is X = exp{Y} where Y is a normal(µ, σ2) random  Find the mean of this distribution. Show that the coverage probability does not depend on µ but does depend on σ. Use simulations to estimate the coverage probability and the probability that the interval will contain negative values of the true mean for different values of σ and increasing sample sizes.STAT代写

#### Q.5 [STAT6CI3] Prove Theorem 10 in mynotes as follows.

a)Showthat for an arbitrary sampling density g, with the same support as f , the variance of the importance sampling estimator is

b)Show that when the sampling density g is givenby

g(x)    |h(x)|f (x)

this variance reduces to and prove that this variance is less than or equal to the variance in (a).STAT代写

Hint: For any random variable Y , Var(Y ) = E(Y 2) .E(Y )Σ2 “ 0. 