Sale!

STA442H1 Assignment 1 Solved

Original price was: $40.00.Current price is: $35.00. $29.75

Category:

Description

5/5 - (1 vote)

1. Let Y ∼ Bin(n = 30, π = 0.9). Y can be interpreted as the number of successes in a sample
of size n = 30 from a Binomial distribution with probability of success π = 0.9.
(a) Let the observed number of success after 30 trials is y = 27. Calculate Wald and score
(Wilson) 95% confidence interval. [5 Marks]
(b) Simulate N = 100, 000 observations of Y using R function rbinom(). Calculate the Wald
and Score 95% confidence interval for each of the observations. This means you are
calculating 100, 000 confidence intervals of each type. Calculate the proportion of these
Wald intervals that contain 0.9 (the true value of π). Also calculate the proportion of
score intervals that contain 0.9. Compare the results and comment on your findings.
Which one do you feel is a more reliable CI. [10 Marks]
Note: R cannot generate random numbers. It only generates “pseudo” random numbers.
Thus a seed needs to be provided to reproduce the results. One can fix the seed in R
using the set.seed() command. The seed you are going to use is your student ID. Thus
you have to start the code with set.seed(Your student ID). If you don’t provide the
seed you will loose 3 Marks.
1
2. Same as the previous question Let Y ∼ Bin(n = 30, π) and y = 27. This time we don’t know
the true value of π
(a) Find the likelihood (ℓ(π)) and log-likelihood function (L(π)) [2 Marks]
(b) Using R, find the maximum likelihood estimate of π and plot ℓ(π) and L(π) over the
values of π. [5 Marks]
(c) Test H0 : π0 = 0.5 vs Ha : π ̸= 0.5 using the likelihood ratio test. [3 Marks]
(d) Using R calculate the 95% likelihood ratio confidence interval for π [5 Marks]
2
3. (a) Perform the following simulation (for this please set the seed to your student ID),
• Generate 500 random values from X1 ∼ Uniform[−10, 10], X2 ∼ N(0, 4) and X3 ∼
Bernoulli(0.7)
• Set β = (−0.8, 0.1, 0.2, 0.3)
• Simulate Yi ∼ Poisson(µi), where, µi = exp(∑
j
xijβj )
[10 Marks]
(b) Estimate the βs using Iteratively Weighted Least Square (IRLS) method by writing your
own function. Explain the procedure and state the W matrix as mentioned in lecture 4.
Compare the results with glm code in R [15 Marks]
3