MATH 324 Winter 2022 Final Project
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
MATH 324 Winter 2022
Final Project
The density function of a gamma distribution is
f (z; a, A) = Aa za-1 e-Az , 0 _ z < <
1. (5 marks) Given that the first two moments of the gamma distribution are
a
_1 = E(Ⅹ) =
A2 ,
show that _1
_2 _ _1(2) ,
_1(2)
a =
2. (5 marks) Show that the method of moment estimates are
Ⅹ
and
= Ⅹi(2) _ (Ⅹ)2 .
3. (5 marks) Show that the log likelihood function of an i.i.d. sample, Ⅹ1 , . . . , Ⅹn from a gamma distribution, is
n n
X(a, A) = na log A + (a _ 1) log Ⅹi _ A Ⅹi _ n log Γ(a).
i=1 i=1
4. (5 marks) Show that the MLE for a, which is denoted by , is the solution of the following equation
n Γ/ ()
Γ()
i=1
5. (5 marks) Show that the MLE for A is
=
Ⅹ .
6. The file gamma-arrivals contains gamma-ray data, collected from a satellite launched by NASA in 1991 (http://cossc.gsfc.nasa.gov/). It consists of the times between arrivals (interarrival times) of 3,935 photons (units are sec- onds). You can load the data using the following commands in R
file1<-paste0("https://raw.githubusercontent.com/ " , "mcgillstat/regression/main/data/gamma-arrivals.csv")
# read the csv data file
dat <- read.csv(file=file1,header = FALSE)
# define the column name of the dataset
colnames(dat) <- "times"
# for demonstration, print the first six rows of the matrix
head(dat)
## ## 1 ## 2 ## 3 ## 4 ## 5 ## 6
times
38
409
272
99
88
80
(a) (5 marks) Make a histogram of the interarrival times. Does it appear
that a gamma distribution would be a plausible model? You can use the following code the generate the histogram.
hist(dat$times)
(b) (5 marks) Fit the parameters a and A by the method of moments, using
the formula derived in part 2.
Hint: you can compute Ⅹi(2) of the data by using
mu2_hat = mean(dat$times^2)
mu2_hat
## [1] 12701
(c) (5 marks) Fit the parameters a and A by maximum likelihood, using the formula derived in part 3 and 4. From part 4, we obtain a nonlinear equation for the mle of a
1 n Γ/ ()
n Γ()
This equation cannot be solved in closed form; an iterative method for finding the roots has to be employed. The following R code will help you find the root of the equation:
x = dat$times
x_bar = mean(x)
n = length(x)
f <- function(alpha){
log(alpha) - log(x_bar) + mean(log(x)) - digamma(alpha) }
res = uniroot(f, lower = 0.01 , upper = 2)
alpha_hat = res$root
alpha_hat
## [1] 1
(d) (5 marks) How do the estimates from the mothod of moments and those from the MLE compare?
2022-04-28