Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Stat 135 Fall 2023 – Homework 4

Method of Moments, Maximum Likelihood, and Bootstrapping with R.

Read section 8.4-8.5.0, of the textbook and your class notes.

Mathematical  Statistics  and  Data  Analysis,   3rd  ed.    by  John Rice.   To obtain  full credit, please write clearly and show your reasoning.

Problem 4A  (intro to MLE)   Suppose that X is a discrete random variable with probability function

P(X = 0|θ) = θ,      P(X = 1|θ) = θ,      P(X = 2|θ) = (1 - θ),      P(X = 3|θ) = (1 - θ),

where 0 ≤ θ ≤ 1 is an unknown parameter.  The following 10 independent observations were taken from such a distribution:  (3, 0, 2, 1, 3, 2, 1, 0, 2, 1).  (Equivalently, these are the values of a sample often i.i.d. random variables X1 , . . . , X10, each with the above probability function.)

(a) What is the likelihood function ℓ(θ) for the above sample?  (Note:  in class I called this lik(θ).) What is the log-likelihood function L(θ)?  (Note: in class I called this l(θ)).

(b)  Compute the value of θ that maximizes the probability of the above sample:  that  is, compute the

maximum likelihood estimate θ(欢)ML for the above sample (by setting L (θ) = 0, and then solving for θ).

(c) Now suppose that we have a generic sample of size n, i.e. of the type X1  = x1 , X2  = x2 , . . . , Xn  = xn , where xi  ∈ {0, 1, 2, 3}.  Express the likelihood function ℓ(θ) and the log-likelihood L(θ) in terms of

n0     =   # of samples that are equal to 0,

n1     =   # of samples that are equal to 1,

n2     =   # of samples that are equal to 2,

n3     =   # of samples that are equal to 3.

Note that n = n0 + n1 + n2 + n3  (the total number of samples).  Find θ(欢)ML  in terms of the above ni s.

Problem  4B  In Problem 4A we had n i.i.d. random variables X1 , X2 ,  . . . , Xn, each with probability function

P(X = 0|θ) = θ,

P(X = 1|θ) = θ,

P(X = 2|θ) = (1 - θ),

P(X = 3|θ) = (1 - θ),

(1)

where θ is an unknown parameter. Assuming that ni  = “# of samples that are equal to i”, for i = 0, 1, 2, 3

(note that n0

θ(欢)ML = .

+n1 +n2 +n3  = n) you found that the Maximum Likelihood Estimate (MLE) of θ is given by If we want to study its statistical properties then we must write it as a random variable, i.e.

N0 + N1

n

where we have used the random variables Ni  = “# of observations in the sample that are equal to i”, whose probability distributions depend on (1).

(a) Show that (2) is an unbiased estimator of θ, i.e. that E(θ(欢)ML ) = θ .  Hint:  First ind the probability

function of the random variable Y = N0 + N1, which is the number of elements of the sample X1 , X2 , . . . , Xn  that are equal to either 0 or  1 (note that n is ixed). What is P(Y = k), for k = 0, 1,... ,n?

(b) Compute Var(θ(欢)ML ) in terms of the parameter θ .

Problem 4C. Now, let’s go back to our favorite’ probability distribution from exercises 3A and 3B. Suppose that we have n i.i.d. random variables X1 , X2 , . . . , Xn, each with the following probability function (as usual, 0 ≤ θ ≤ 1 is unknown):

P(X = 0|θ) = θ,

P(X = 1|θ) = θ,

P(X = 2|θ) = (1 - θ),

P(X = 3|θ) = (1 - θ).

(a) Find θ(欢)mm , i.e. the method of moments estimate of θ (it will depend only on µ(欢)1  = X).

(b) Compute the standard error of θ(欢)mm  (i.e. its standard deviation σθ(八)mm ).  Note that it is a function of θ .

(c) How does the standard error of σθ(八)mm  compare to the standard error of σθ(八)ML , for diferent values of θ? Hint:  It is in fact a bit simpler to compare their squares, i.e. Var(θ(欢)mm ) with Var(θ(欢)ml ).

(d) Finally, assume that we have a sample size of n = 10 with sample values (3, 0, 2, 1, 3, 2, 1, 0, 2, 1),

like we had in Problem 4A. Compute:  (i) the ML estimate  θ(欢)ml  (it is a number!)  and its estimated

standard error; and (ii) the MM estimate θ(欢)mm  and its estimated standard error.

Problem 4D   Do problem 8.23

Exercises 4E-4J are one big project broken into pieces.  Do them in order, otherwise things won’t make sense. Convert your HTML into a PDF ile to turn into gradescope.

Problem 4E   Read and thoroughly absorb Example C of Section 8.4.  (Yes, thats the exercise.  No, theres nothing to turn in. Im not kidding. Read Exercise 7 and youll see what I mean.) In class I introduced the Gamma distribution with shape parameter r instead of shape parameter α as given in the book.  I will stick with this notation here.

Problem 4F   Pick an r uniformly at random in the interval (2, 4).  Pick a λ uniformly at random in the interval (1, 2).  For the duration of this assignment, these are your own personal true values of r and λ in the gamma density. Generate an i.i.d. sample of size 200 from your gamma density, and save the sample so  that you  can  use  it  for  the  exercises  below.  As your answer to this exercise, provide your true values of r and λ, and a histogram of your sample with the true gamma density superimposed.

Problem 4G (parametric bootstrap) Pretend you never knew the true values of the parameters.  Com-

pute the MOM estimates r(ˆ) and λ(ˆ) from the sample you saved in Exercise 4F.

Next, generate 1000 independent samples, each of which consists of 200 i.i.d. observations from the gamma

density whose parameters are given by r(ˆ) and λ(ˆ).  Compute MOM estimates of r and λ from each sample. You

now have 1000 simulated estimates of r and of λ.  Draw the histogram of the distribution of each estimate, as in Figure 8.4 of your text.  Comment on the shapes of the distributions  (compare with Figure 8.4) and calculate the approximate standard error of each estimate.  And, inally, recall that you do know dthe true values of r and λ. Mark each of them on the horizontal axis of the appropriate histogram.  Is either of them in a surprising place? Oh, by the way - congratulations. You are now a parametric bootstrapper.

Problem  4H Pick two estimates of r:  one at the 5th percentile of the distribution of estimates  of r in Problem 4G, and the other at the 95th percentile.  On a single graph, draw the histogram of your original sample and three gamma density functions: the true density, and one for each of your two chosen estimates of r (with λ in both cases equal to the MOM estimate from Problem 4G). Use three diferent line colors to distinguish the three curves.  Comment on what you see.  Is it more or less what you expect, or is there something surprising?

Problem 4I  (nonparametric bootstrap)

Another way to bootstrap is by resampling. As in Exercise 4G, the idea is to get the sampling distribution of your estimate by simply drawing lots of samples, computing the estimate from each sample, and noting that the observed distribution of the estimates is likely to be pretty close to the true sampling distribution. The problem lies in how to draw lots of samples when you dont know exactly what youre drawing from. Problem 4G showed one way around this, by plugging in MOM estimates in place of the true values.

Heres another way that is simple and clever. Treat your original sample (the one you saved in Problem 4F) as a clone of the population, and draws lots of i.i.d.  samples from it! Thats resampling.

That is, draw 1000 independent samples, each consisting of 200 independent draws from the original sample. From each of the new samples, get MOM estimates of   and   and draw the histograms of your estimates. As in Problem 4G, comment on the shapes, compute the approximate standard errors, and mark the true values of the parameters on the horizontal axes. Now compare with the distributions in Problem 4H.

Problem 4J

Find the MLEs of r and λ as we did in the in-class exercise for the participation data (Example C of Section 8.5).  Use your MOM estimates in Problem 4G as the initial values in the minimizing function.  Compare with the true values of r and λ .