程序代写案例-MAST20005
时间:2021-02-16
Final exam solutions
MAST20005 Statistics
Semester 2, 2017
1. (a) E(X) = 3θ and var(X) = E(X2)− E(X)2 = 5θ − 9θ2 = θ(5− 9θ)
(b) i. Let the sample frequencies of the three values be n0, n1, n2. The likelihood is L(θ) =
(1− 2θ)n0θn1θn2 = (1− 2θ)n0θn1+n2 , and therefore the log-likelihood is:
l(θ) = n0 log(1− 2θ) + (n1 + n2) log θ.
Note that n0 + n1 + n2 = n, so an alternative expression for the log-likelihood is:
l(θ) = n0 log(1− 2θ) + (n− n0) log θ.
ii. ∂l
∂θ
= − 2n0
1−2θ +
n−n0
θ
= 0 ⇒ θˆ = n−N0
2n
= N1+N2
2n
.
iii. A sufficient statistic is n0, the number of 0’s. An equivalent alternative is n1 + n2 =
n− n0, which is the sum of the number of 1’s and 2’s.
iv. Note that N0 ∼ Bi(n, 1− 2θ), which means that E(θˆ) = n−n(1−2θ)2n = θ, and therefore
the MLE is unbiased.
v. − ∂2l
∂θ2
= 4n0
(1−2θ)2 +
n−n0
θ2
⇒ I(θ) = E
(
− ∂2l
∂θ2
)
= 4n(1−2θ)
(1−2θ)2 +
n−n(1−2θ)
θ2
= 4n
1−2θ +
2n
θ
=
4nθ+2n(1−2θ)
θ(1−2θ) =
2n
θ(1−2θ) . Therefore, the lower bound is
1
I(θ)
= θ(1−2θ)
2n
.
vi. var(θˆ) = 1
4n2
var(N0) =
1
4n2
n(1 − 2θ)(2θ) = θ(1−2θ)
2n
. Therefore, the MLE achieves the
lower bound.
(c) i. We have n0 = 8, n1 = 4, n2 = 8. This gives θˆ =
12
2×20 = 0.30. To get a standard
error we substitute this for θ into the expression for the variance of θˆ, which gives,
se(θˆ) =

0.3× 0.4/40 = 0.055.
ii. Based on the above results, we know that θˆ ≈ N(θ, 0.0552). Therefore, an approxi-
mate 95% confidence interval is given by θˆ ± 1.96× 0.055 = (0.19, 0.41).
Note: Using either the observed information function or the Fisher information func-
tion will lead to the same result. In particular, J(θˆ) = I(θˆ) = 4n
3
n0(n−n0) = 1000/3. An
exact alternative is an interval based on F0, which follows a binomial distribution.
This gives a very similar result:
> round((1 - rev(binom.test(8, 20)$conf.int)) / 2, 2)
[1] 0.18 0.40
iii. The expected counts (based on θˆ) are: 8, 6, 6. The test statistic is:
χ2 =
(8− 8)2
8
+
(4− 6)2
6
+
(8− 6)2
6
=
4
3
= 1.33.
We have estimated one parameter so have a test with 1 degree of freedom. The 0.95
quantile of a χ21 distribution is 3.84. Since 1.33 < 3.84, we cannot reject H0.
1
iv. It will not be possible, there will be no degrees of freedom remaining to carry out the
test. The resulting model will be simply a binomial distribution. (Once we estimate
the probability parameter for the binomial, we get a ‘perfect’ (saturated) fit to the
data and cannot test for deviations.)
2. (a) i. Let the sample frequencies of the three values be N0, N1, N2. The MM estimate is
obtained by solving 3θ = X¯, which gives θ˜ = 1
3
X¯ = N1+2N2
3n
.
ii. E(θ˜) = 1
3
E(X¯) = 1
3
E(X) = θ, and therefore the MM estimator is unbiased.
iii. var(θ˜) = 1
9
var(X¯) = 1
9
var(X)
n
= θ(5−9θ)
9n
. Note that,
var(θ˜) =
θ(5
9
− θ)
n
>
θ(1
2
− θ)
n
= var(θˆ) =
1
I(θ)
,
So we can see that the MM estimator does not achieve the lower bound.
iv. From above, we see that both estimators are unbiased but the MLE has lower variance,
so the MLE is a better estimator in this scenario.
(b) i. We have n0 = 8, n1 = 4, n2 = 8. This gives θ˜ =
20
3×20 =
1
3
= 0.333. To get a standard
error we substitute this for θ into the expression for the variance of θ˜, which gives,
se(θ˜) =

1
3
× 2
180
=
1√
270
= 0.061.
ii. The MM estimator is based on the sample mean and so due to the Central Limit
Theorem will be approximately normally distributed. Based on the above results, we
know that θ˜ ≈ N(θ, 0.0612). Therefore, an approximate 95% confidence interval is
given by θ˜ ± 1.96× 0.061 = (0.21, 0.45).
3. (a) These are paired samples so we first calculate the differences and treat those as coming
from a single normal distribution. We get the following summary statistics for the differ-
ences: d¯ = 3.4 and sd = 3.75. The sample size is n = 10 and we need the 0.975 quantile of
t9 which is 2.26. A 95% confidence interval is given by: 3.4±2.26×3.75/

10 = (0.72, 6.1).
(b) i. H0 : µ1 = µ2 and H1 : µ1 6= µ2.
ii. Use the t-test statistic on the differences, T = D¯
SD/

10
.
iii. T ∼ t9 under the null and its 0.975 quantile is 2.26. Therefore, reject H0 if |t| > 2.26.
iv. t = 3.4/(3.75/

10) = 2.87 > 2.26 so therefore reject H0.
4. (a) Using the standard approximation for a single proportion, pˆ1 = 260/500 = 0.520, se(pˆ1) =√
0.52×0.48
500
= 0.0223, so a 95% confidence interval is pˆ1 ± 1.96 se(pˆ1) = (0.48, 0.56).
(b) We need to account for the sampling variation in both polls in any comparison. Using
the standard comparison of two proportions, pˆ2 = 255/520 = 0.490, pˆ2 − pˆ1 = −0.0296,
se(pˆ2 − pˆ1) =

0.52×0.48
500
+ 0.49×0.51
520
= 0.0313, so a 95% confidence interval is pˆ2 − pˆ1 ±
1.96 se(pˆ2 − pˆ1) = (−0.091, 0.032). Differences in both a positive and negative direction
are plausible, which means we do not have strong evidence for a change between the two
polls. We certainly cannot draw as strong a conclusion as what the newspaper reported.
(c) It needs to be n > 1.962/ (4× (0.01)2) = 9604.
2
(d) Let p be the proportion of the population who support the Purple Party. The test is
H0 : p = 0.5 versus H1 : p > 0.5. Use the standard test for a single proportion: reject H0 if
pˆ−p0√
p0(1−p0)/n
> c. We have p0 = 0.5, n = 2000 and c = Φ
−1(0.95) = 1.645, so the rejection
rule simplifies to: 2

n(pˆ− 0.5) > 1.645. Under H1, we have pˆ ≈ N(p, p(1− p)/n). With
a bit of algebraic manipulation, we can show the power function is:
K(p) = Pr(2

n(pˆ− 0.5) > 1.645 | p) = Φ
(
2

n(p− 0.5)− 1.645
2

p(1− p)
)
0.50 0.51 0.52 0.53 0.54 0.55
0.
0
0.
2
0.
4
0.
6
0.
8
1.
0
p
Po
w
e
r
(e) Use n = 2000 and p = 0.53 to give β = 1−K(0.53) = 1− Φ(1.04) = 1− 0.851 = 0.149
5. (a) This is a sample from a binomial distribution so the MLE is pˆ = 1
40
= 0.025.
(b) The conjugate prior for a binomial likelihood is a beta distribution.
(c) We want p ∼ Beta(α, β) where the α and β can be interpreted as pseudocounts. We
require that α+β = 5 and also that E(p) = α
α+β
= 0.01. Solving these gives α = 0.05 and
β = 4.95.
(d) The posterior is p | data ∼ Beta(1 + α, 39 + β) = Beta(1.05, 43.95).
(e) Posterior mean: E(p | data) = 1.05
45
= 0.023. Central 95% credible interval: (0.0007, 0.0826).
3
6. This is a standard contingency table scenario. The observed and expected frequencies are:
Symptoms
Worse Same Better
Placebo O 15 10 18
E 9.46 6.45 27.09
Drug O 7 5 45
E 12.54 8.55 35.91
The test statistic is:
χ2 =
(15− 9.46)2
9.46
+ · · ·+ (45− 35.91)
2
35.91
= 14.47.
The 0.99 quantile of a χ22 distribution is 9.21. Since 14.47 > 9.21, we reject H0.
7. (a) i. According to the exponential model, E(X) = sd(X) = θ. The Central Limit Theorem
then implies θˆ = X¯ ≈ N(θ, θ2/n).
ii. θˆ = x¯ = 3.9.
iii. se(θˆ) = θˆ/

n = 3.9/

9 = 1.3. An alternative solution is to use the sample standard
deviation directly, se(θˆ) = s/

n = 0.82. This avoids making the exponential distribu-
tion assumption so is more robust, but is less accurate if the exponential distribution
is indeed true. Both are valid solutions to the question.
(b) i. The median of an exponential distribution with mean θ is θ log 2. You can derive this
easily from the cdf: 0.5 = F (m) = 1 − e−m/θ ⇒ m = θ log 2. The sample median is
asymptotically unbiased, which means E(Mˆ) ≈ θ log 2. Therefore, it is biased for θ.
ii. According to the above, letting c = 1/ log 2 makes T asymptotically unbiased.
iii. Asymptotically, Mˆ ≈ N(m, 1
4nf(m)2
). The pdf is f(x) = 1
θ
e−x/θ, so we have f(m) =
f(θ log 2) = 1
θ
e− log 2 = 1

. This gives, Mˆ ≈ N(θ log 2, θ2
n
). Therefore, T ≈ N(θ, θ2
n(log 2)2
).
iv. Both X¯ and T are asymptotically unbiased but X¯ has smaller variance: var(T ) ≈
θ2
n(log 2)2
= 2.08 θ
2
n
≈ 2.08 var(X¯) > var(X¯). Therefore, X¯ is the better estimator.
v. t = mˆ/ log 2 = 1.443x(5) = 1.443× 3.5 = 5.05
vi. se(t) = t√
n log 2
= 2.43
8. (a) L(θ) =
∏n
i=1
2xi
θ2
∝ θ−2n with θ > x(n). This is maximised on the boundary, θˆ = X(n).
(b) F (x) =
∫ x
0
f(y) dy =
(
x
θ
)2
. The pdf of the MLE is G(x) = Pr(X(n) 6 x) = Pr(X 6
x)n = F (x)n =
(
x
θ
)2n
. The p-quantile of this distribution satisfies p = G(pip) =
(pip
θ
)2n
.
Rearranging gives pip = θp
1/(2n). For a central 95% confidence interval, we need bounds
based on p = 0.025 and p = 0.975,
0.95 = Pr(θ × 0.0251/(2n) 6 X(n) 6 θ × 0.9751/(2n))
= Pr(X(n) × 0.975−1/(2n) 6 θ 6 X(n) × 0.025−1/(2n)).
Therefore, a 95% confidence interval is given by (x(n) × 0.975−1/(2n), x(n) × 0.025−1/(2n)).
(c) n = 6, x(6) = 4.8, 0.975
−1/12 = 1.002112, 0.025−1/12 = 1.359894, and a central 95%
confidence interval for θ is (4.81, 6.53).
4



















































































































































































































































































































































学霸联盟


essay、essay代写