辅导案例-MA40198

欢迎使用51辅导,51作业君孵化低价透明的学长辅导平台,服务保持优质,平均费用压低50%以上! 51fudao.top
MA40198: Applied Statistical Inference
2020 coursework sheet
Deadline: Friday 11 December 2020 at 5 PM
General Instructions
Guidelines on the structure and submission of the coursework appear at the end of this document and in the
unit’s Moodle page. This coursework is worth 40% of the mark for the unit.
Models for count data
The Poisson distribution is the simplest probability model for count data, e.g. taking values 0, 1, 2, . . .. The
corresponding probability mass function is given by:
f(y|µ) = exp(−µ) µ
y
y! y = 0, 1, 2, 3, 4, ....
where µ = E[Y ] = V ar[Y ] which is a special property of the Poisson distribution.
A slightly more general probability model is given by the Negative Binomial distribution with probability
mass function:
f(y|µ, η) = Γ(η + y)Γ(y + 1)Γ(η)
(
η
µ+ η
)η (
µ
µ+ η
)y
y = 0, 1, 2, 3, 4, ...
where µ = E[Y ] > 0 and η > 0. The corresponding variance is given by
V ar[Y ] = µ
(
1 + µ
η
)
When η →∞ then the Negative Binomial distribution tends to the Poisson distribution with the same mean
µ. In this sense, we say that the Negative Binomial is overdispersed with respect to the Poisson.
In R, the density function of the Negative Binomial is computed using the function dnbinom(x, size,
prob, mu, log = FALSE) where
• x is the count variable in cuestion.
• size corresponds to the parameter r.
• mu corresponds to the mean µ.
• prob is the probability of success, like in the Binomial, but we do not need it here since we will use the
mean parametrisation µ.
• log if log=TRUE then the function returns the log density.
1
Relevant functions in R are gamma to evaluate the Gamma function Γ and lgamma to evaluate the logarithm
of the Gamma function. Note that automatic differentiation in R via deriv is able to differentiate twice both
gamma and lgamma.
Another general count data model is the generalised Poisson distribution which has densities:
f(y|λ, β) = λ
y
(y!)β
1
K(λ, β)
where λ > 0, β > 0 and K(λ, β) is the normalisation constant, that is
K(λ, β) =
∞∑
i=0
λi
(i!)β
When β = 1 the generalised Poisson turns into the Poisson distribution with mean λ. There is no closed
formula to compute K(λ, β) exactly so it will have to be computed numerically by truncating the infinite
series, namely using:
k∑
i=0
λi
(i!)β
with a value of k as large as possible. When β < 1 then there is overdispersion with respect to the Poisson,
that is, V ar[Y ] > E[Y ] and when β > 1 then there is underdispersion, that is V ar[Y ] < E[Y ].
Consider the following sample y1, . . . , y100 which is distributed according to some unknown probability density
function f∗(y) with support Y = {0, 1, 2, . . .}.
Let µ∗ and σ∗ be the mean and standard deviation corresponding to f∗(y), that is
µ∗ := E∗(Y ) =
∞∑
y=0
yf∗(y) , [ν∗]2 := Var∗(Y ) =
∞∑
y=0
(y − µ∗)2 f∗(y)
1.1
Find the MLE µˆP of µ∗ and the MLE θˆP of θ∗ under the assumption that the data is Poisson distributed. [4
marks]
1.2
Assuming the data is Poisson distributed, construct an asymptotic 95% confidence interval for µ∗ using the
asymptotic normality of µˆP . [4 marks]
1.3
Assume the data is Poisson distributed and let θ∗ = log(µ∗). Construct an asymptotic 95% confidence interval
for µ∗ using the asymptotic normality of θˆP . Indicate which estimator of asymptotic variance you used. [8
marks]
1.4
Assume the data is distributed as negative Binomial and let λ∗ = log(η∗). Find the MLE (µˆNB , ηˆNB)T of
(µ∗, η∗) and the MLE (θˆNB , λˆNB)T of (θ∗, λ∗)T . [6 marks]
2
1.5
Assuming that the data is distributed as negative Binomial, construct an asymptotic 95% confidence interval
for µ∗ using the asymptotic normality of θˆNB . Indicate which estimator of the asymptotic variance you used.
[6 marks]
1.6
Assuming that the data is distributed as negative Binomial, construct an asymptotic 95% confidence interval
for the standard deviation ν∗. Indicate clearly which asymptotic normality result and which estimator of
asymptotic variance you used. [8 marks]
1.7
Find an asymptotic 95% confidence interval for µ∗ assuming the data is generalised Poisson. Indicate clearly
which asymptotic normality result and which estimator of asymptotic variance you used. [10 marks]
1.8
Using a significance level of α = 0.05, test the hypotheses:
H0 : Data is Poisson vs. Ha : Data is Generalised Poisson but not Poisson
[4 marks]
1.9
Assume the data is Negative Binomial and let
p∗ = η

η∗ + µ∗
Assume that
• the prior distribution for log(p ∗ /(1− p∗)) is Normal with mean 0.5 and standard deviation 0.1
• the prior distribution for log(η∗) is Normal with mean 2 and standard deviation 0.3
• log(p ∗ /(1− p∗)) and η∗ are independent under the prior
Draw a sample of size N = 10, 000 from the posterior distribution of µ∗ and use it to compute an equally
tailed posterior probability interval for µ∗ with probability content 0.95. [10 marks]
1.10
Assume the data is generalised Poisson. Consider the following prior density for θ∗ = (log(λ∗),−β∗)T
f(θ) ∝ exp(θ1(a1 − 1) + θ2a2 − a3Ψ(θ))
where Ψ(θ) = logK(exp(θ1),−θ2) with K the normalising constant of the generalised Poisson. The values
a1, a2, a3 are known constants that must satisfy the constraint
a2
a3
> log
(⌊
a1
a3

!
)
+
(
a1
a3


a1
a3
⌋)
log
(
1 +

a1
a3
⌋)
3
where buc denotes the floor of u. Draw a sample of size N = 10, 000 from the posterior distribution of µ∗ and
use it to compute an equally tailed posterior probability interval for µ∗ with probability content 0.95. [8
marks]
Count regression
Consider the following data which is a series of counts over the range ([−10, 10]) of a standardised variable x.
dat<-read.table(url("https://people.bath.ac.uk/kai21/ASI/CW2020/CW20_q2.txt"),header = T)
Let Yx be the random variable corresponding to the count at x . Consider the following possible model
specifications:
• Y−10, Y−9, . . . , Y−1, Y0, Y1, . . . , Y9, Y10 are independent random variables with unknown mean µ∗x for
x = −10, . . . , 10
• Yx ∼ Poisson(µ∗x) or Yx ∼ Negative Binomial(µ∗x, η∗) for x = −10, . . . , 10 where η∗ is also unknown.
• log(µ∗x) =
∑p
i=0 θ

i x
i. We consider p = 1, 2, . . . , 6
The above specifications generate 12 different models.
2.1
Plot the the counts against the variable x [2 marks]
2.2
For each of the 12 models, compute the maximum likelihood estimates for the corresponding unknown
parameters. You should use optim with the BFGS method and supply the corresponding gradient function.
Please note that given the number of models, you should consider using the R function deriv to obtain the
gradient functions. [12 marks]
2.3
For each of the 12 models, compute the corresponding values of Akaike information criterion (AIC), Bayesian
information criterion (BIC) and Network information criterion (NIC) . Plot these as function of p, the order
of the polynomial. According to each information criterion which one is the best model?
[8 marks]
2.4
Plot the data (x against yx) together with the corresponding estimated mean curves, that is µˆx which are
obtained by substituting the mle’s of the parameters of each model into the corresponding mean function µx.
What is the relation between the values of each information criterion for each model with the corresponding
fits of the mean curve to the the data? For each model, compute predictions for the mean number of counts
in x ∈ {−15,−14,−13,−12,−11, 11, 12, 13, 14, 15} and plot these with the data and the estimated mean
curve. . [10 marks]
4
Submission guidelines
• You should submit only two files: one PDF file with your answers and supporting information and an
R file (or RMD file) with your code (see below for details).
• In the PDF file, all the answers should be provided in two parts. In the first part (labelled Answer
to question X.X), you should ONLY provide the answer to what has been asked. In the second
part (labelled supporting information for Question X.X) you should provide any supporting
information such as mathematical derivations or explanations (not code, see below for coding rules).
• In your supporting information, please make clear reference (equation numbers, Theorem numbers,
sections, etc) to any unit material such as the lecture notes, question sheets, etc. You can make reference
to other external material.
• Remember to clearly label the axes of your plots as well as providing them with a title or caption where
possible.
• In the R or RMD file, you should ONLY submit the R code used to produce your answers. You should
clearly indicate the question that each section of code corresponds to. The R code submitted should be
reproducible in the sense that the lecturer should be able to reproduce your numerical results, plots etc
if necessary and comments in your code are specially useful for this purpose.
• The two coursework files must be submitted electronically on the MA40198 Applied Statistical Inference
Moodle page. There will be a section dedicated to the electronic submission.
• Work may be subject to electronic plagiarism screening, and other investigations to check that it is
your own.
• The coursework files must be uploaded by 5 PM Friday 11th December 2020.
Posterior samples guidelines
• Specify clearly the proposal distributions used
• Choose suitable starting values for the parameters and indicate the burn-in period used
• Tune the proposal distribution iteratively to reach an acceptance rate of about 25%
5

欢迎咨询51作业君
51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: abby12468