STA261H1S Term Test 2 (Wed Afternoon)
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
STA261H1S Term Test 2 (Wed Afternoon)
2022
Question 1
The following questions are based on confidence intervals.
(a) [4 Marks] Let, (2.00, 3.26, 2.84, 4.77, 3.23, 3.64, 1.84, 4.43, 1.35, 2.28) N (µ, σ2 ) with µ ∈ R and σ 2 is unknown. Calculate a 90% confidence interval for µ .
Solution:
rm(list = ls())
set.seed(100)
x <- rnorm(10, mean = 3, sd = 2)
round(x, 2)
## 90% CI for the mu ##
gam <- 0.9
xbar <- mean(x); xbar
s2 <- var(x)
SE <- sqrt(s2/length(x))
ll <- xbar - qt((1+gam)/2, df = length(x) - 1) * SE
ul <- xbar + qt((1+gam)/2, df = length(x) - 1) * SE
paste0("90% CI is:", " (", round(ll, 2), ", ", round(ul, 2), ")")
[1] "90% CI is: (2.31, 3.61)"
Thus the 90% CI is = (2.31, 3.61)
(b) [5 Marks] Using the same data set provided in (a), calculate the left sided 95% confidence interval for σ 2 .
Solution:
The shortest confidence interval here will be the left side confidence interval. Thus the lower limit is 0. We just need to calculate the upper limit,
## 95% shortest CI for the mu ##
def <- length(x) - 1
gam <- 0.95
chis <- qchisq(1 - gam, df = def)
ll <- 0
ul <- def*s2 /chis
paste0("95% CI is:", " (", round(ll, 2), ", ", round(ul, 2), ")")
[1] "95% CI is: (0, 8.82)"
[1] ”95% CI is: (0, 3.41)”
Question 2
(a) [5 Marks] A tow sided 95% confidence interval for µ in the location Normal model N(µ, σ0(2)), calculated from a an observed sample is (50, 60). ( Note: sample size is not given to you)
Calculate the lower limit of the 80% confidence interval for µ, using the data from the same sample.
Solution
= = = 55
z(1+0.80)/2 = 1.282
ME = U L = 60 50 = 5
σ0 ME = 2.55102
Lower limit of the 80% confidence interval
N(=)ot(x¯)do(.80)t(2)ed(=) n(5)5 fo(8)r(×)th(2.)ti(=)on(51) .73469 ■
(b) [8 Marks] Using R, I generated a sample of 64 observations from a Poisson(λ) distribution and calculated an approximate two sided 95% confidence interval for λ using the approximation based on the central limit theorem. The lower limit of this confidence interval is L = 2.64. Calculate the upper limit of this confidence interval.
Solution
L = − z √ =⇒ − √ − L = 0
z ± √ +4L 1 .96 ± √ +4 ×2 .64
■
Question 3
Suppose that x = (1, 1, 0, 0, 1) is an observed sample from Bernoulli(θ) distribution and the prior
distribution of θ has p.d.f.:
π(θ) = {0(5)θ4 ,
(a) [5 Marks] Calculate the posterior expectation of θ 2 .
Solution: Note that the prior distribution of θ is beta(5,1) and thus the posterior distribution is beta(5+3 = 8, 1 + 2 = 3)
π(θ | s) = θ 7 (1 − θ)2
Thus, the posterior expectation of θ 2 ,
E(θ2 | s) = θ 9 (1 − θ)2 dθ = = 0.5454545
Note for TA: Please check for any potential error in the solution.
(b) [5 Marks] Calculate the posterior expectation of .
Solution: Thus, the posterior expectation of 1/θ ,
E(θ−1 | s) = θ 6 (1 − θ)2 dθ = = 1.428571
Question 4
(a) [5 Marks] I generated a sample from a location Normal model with σ0(2) = 16. The 95% confidence interval for the mean (µ) calculated using this sample I generated is (58.7, 61.9). This interval has all the information necessary to test the null hypothesis H0 : µ = 59 against the alternative H1 : µ > 59. Calculate the value of the observed z-statistic and the critical z-value for the z-test of the null hypothesis H0 : µ = 59 against the alternative H1 : µ > 59. Assume α = 0.05 The 95% confidence interval for the mean (µ) calculated using this sample I generated is (58.7, 61.9) =⇒ SE = =2(61) = 0.8163265
= = 60.3
z = 0 = 068(0)1(.)6(3)2(5)6(9)5 = 1 .59
The critical z-value at α = 0 .05 is Z0 .95 = 1 .645
Since, the calculated z 1.59 < 1.645, thus, we cannot reject the H0 ■
(b) [3 Marks] Calculate the number of observations in this study.
Solution: Let the number of observations = n. We know that
SE = σ0 / √n =2 ⇒ n = (σ0 /0.8163265)2 = 24.01 ≈ 25
Question 5
In a small survey, a random sample of 50 voters from a large population is selected. Each person is asked whether he/she plans to vote for party X. Let the proportion in the population who would answer “Yes” be θ . Our prior distribution of θ is Beta(1.5, 1.5). In the survey 37 individuals answered “Yes”.
(a) [4 Marks] Find the prior mean and prior mode of θ .
Solution: This is a Bernoulli-Beta combination. The prior distribution of θ is a Beta distri-
bution with α = 1.5 and β = 1.5. Thus the mean 1.5/3 = 1/2 and mode 13(.)1 = 0.5. (b) [6 Marks] Find the posterior mean and posterior mode for the distribution of θ .
Solution: The posterior distribution is also a Beta distribution with parameters α = 1 .5 +
n, β = 1.5 + n(1 − ) ⇒ α = 1.5 + 37, β = 1.5 = (50 − 37) ⇒ α = 38.5, β = 14.5. Thus, the
2022-04-12