Midterm 2023 Sol

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

DO NOT OPEN THIS EXAM UNTIL INSTRUCTED TO

Name: Student #:

STAT 404 Midterm Exam


September–December, 2023
Instructor: Jiahua Chen
Total marks: 84+1.

• Put your name and student ID on the up-right corner of every sheet.

• Correct answers are usually short. Answer questions in brief but complete sentences.
If you do not show your work, part marks will not be given if your answer is
incorrect. For example, a satisfactory answer is:
The treatment sum of squares is given by
k
X
SStrt = ni (ȳi· − ȳ·· )2 = 4 × (5 − 3.2)2 + 6 × (2 − 3.2)2 = 21.6 .
i=1

An unsatisfactory answer is:


21.6 .

• Use R for simple calculations such as the sample mean and sample variance (as in the
assignments). Answers obtained using one-line R functions will not be accepted.

• Save the R code you used in a .doc, .docx, .rtf, or .txt file. Include comments
describing which question the code block is used for. Leave sufficient space between code
for different questions. Submit your code to Canvas.

• Unless otherwise specified,

1. assume common notations and model assumptions;

2. use the conventional 5% level for tests, hypothesis for two-sided alternatives, and
95% confidence level.

• Bonus 1 mark will be given to all, unless one’s presentation is judged very
messy.

1
MIDTERM PROBLEMS START HERE

1. [6] List the three principles of design of experiments we discussed in STAT 404.
Explain each principle in 1–2 complete sentences.

Answer.

(a) Randomization: prevents the effect of lurking factors or assigning treatments


to random experiment units (either is fine).

(b) Replication: improves the precision of estimating the treatment effects or re-
peating the same treatment on several experiment units.

(c) Blocking: removes the effect of a factor that is not of interest or grouping simi-
lar experiment units to compare different treatments under similar conditions.

2. [8] The standard two-sample t-test is formulated under strict model assumptions.

(a) [4] Name two of the model assumptions. Describe each assumption in one
sentence.

Answer. Any two of the following (or other relevant assumptions) is acceptable:

• Independence: all observations are independent of each other.

• Normality: all observations have normal distributions.

• Identical variances: the two populations have the same variance.

(b) [4] For each assumption, explain in 1–2 complete sentences how the assumption
affects the standard t-test (based on the lecture discussions).

Answer.

• Independence: without independence, the variance estimate is incorrect.

• Normality: without normality, the numerator of the t-statistic does not have
a normal distribution, and so the test statistic does not have a t-distribution.

• Identical variances: if the populations have different variances, the pooled


variance may not be a reasonable estimate.

Other answers may also be acceptable if correct and answers the question.

2
3. [10] We collected data on the gender, footlength and height of 35 adults. The
dataset (BodyHeight.txt) and code to read in the data are on Canvas.

(a) [4] Test the hypothesis H0 : µm = µf against the one-sided alternative Ha :


µm ≥ µf using a t-test under the equal variance assumption. State the test statistic
and its reference distribution, the p-value or critical value, and your conclusions.

Answer. Using the pooled estimator, the variance is estimated to be s2p = 38.167.
The test statistic is then

ȳ − ȳf
T = qm = 6.158 .
sp n1m + n1f

The test statistic has a t-distribution with nm + nf − 2 = 33 degrees of freedom.


The critical value is the 95% quantile of this distribution, t33 (0.95) = 1.692. We
have T > t33 (0.95) and so we reject H0 . The difference in mean height of males and
females is statistically significant.

(b) [6] Test the hypothesis H0 : µm = µf against the one-sided alternative Ha :


µm ≥ µf using a randomization test. State the p-value and your conclusions. Use
10000 Monte Carlo permutations for this calculation.

Answer.

We observe dobs = ȳm − ȳf = 12.90789.

Because we have a one-sided alternative, extreme differences are differences where


di > dobs , denoted as c1 , or di = dobs , denoted as c2 . (Note we use the actual values
di and dobs , not the absolute values.)
c1 +0.5c2
Defining c1 and c2 as above, we can calculate the p-value as p = 10000
because we
are doing 10,000 simulations, and not going through every combination.

Using a randomization test with 10,000 Monte Carlo permutations, we obtain a


p-value of p = 0 for the one-sided alternative. We reject H0 and conclude that the
mean height of males is significantly greater than the mean height of females.

4. [28] A linear regression model assumes that the response values in a study can be
expressed as

yi = x ⊤
i β + ϵi for i = 1, 2, . . . , n ,

3
where x⊤ 2
i β is the expected value of yi given xi and the ϵi ’s are iid N(0, σ ) random

variables.

You are asked to analyze the same dataset as in Q3: model the height against
gender and footlength (the numbers have been doctored slightly).

• x1 : gender (Male = 1, Female = -1)


• x2 : foot-length
• y: height

Note: in this case, x = (x0 = 1, x1 , x2 )⊤ and β = (β0 , β1 , β2 )⊤ .

(a) [4] Obtain an expression for the expected height of a female with foot-length
25 cm. Hint: it is linear in β0 , β1 and β2 .

Answer. The expected height of a female with foot-length 25 cm is given by

E[Y |x1 = −1, x2 = 25] = β0 − β1 + 25β2 .

(b) [4] Obtain the least squares estimator β̂ of β.

Answer. The LSE of β is

β̂ = (X⊤ X)−1 X⊤ y = (134.734, 4.408, 1.438) .

(c) [4] Compute the predicted height of a female with foot-length 25 cm based on
the fitted linear regression.

Answer. The predicted height of a female with foot-length 25 cm is

ŷ = β̂0 − β̂1 + 25β̂2 = 166.265 cm .

(d) [4] Estimate the error variance σ 2 (use the method given in class).

Answer. The error variance is estimated as

(y − ŷ)2
P
2
σ̂ = = 27.960 .
35 − 2 − 1

4
(e) [4] Estimate the variance matrix of β̂.

Answer. The variance matrix of β̂ is estimated as


 
103.267 5.801 −4.029
 
d β̂) = σ̂ 2 (X⊤ X)−1 = 
Var(  5.801 1.125 −0.225 .

 
−4.029 −0.225 0.158

(f ) [4] Estimate the variance of the predicted height of a female with foot-length
25 cm.

Answer. Let x = c(1, −1, 25). The estimated variance of the predicted height of a
female with foot-length 25 cm is

Var(ŷ)
d d β̂) = σ̂ 2 x⊤ (X⊤ X)−1 x = 1.627 .
= Var(x

(g) [4] Construct a two-sided 95% confidence interval for the height of a female
with foot-length 25 cm. Hint: remember the general recipe for constructing CIs.

Answer. A two-sided 95% confidence interval for the height of a female with
foot-length 25 cm is given by
q √
ŷ ± t32 (0.975) Var(ŷ)
d = 166.263 ± 2.037 1.627 = (163.667, 168.863) .

5. [26] Consider a hypothetical one-way layout comparing k = 5 treatments under


standard model assumptions and notations. The code to load in the data is
on Canvas.

(a) [4] Estimate the treatment effects of the 5 groups (i.e., τ̂j ).

Answer. For i ∈ {1, . . . , 5}, the treatment effects are given by

τi = ȳi. − ȳ.. = (-8.090, -1.690, -6.290, 6.210, 9.265) .

(b) [2] Compute the treatment sum of squares SStrt .

5
Answer. The treatment sum of squares is
5
X
SStrt = ni τi2 = 1714.365 .
i=1

(c) [4] Compute the error (or residual) sum of squares SSerr .

Answer. Let s2i be the sample variance for treatment i. We compute it as


5
X
SSerr = (ni − 1)s2i = 772.022 .
i=1

(d) [4] Complete the one-way layout ANOVA table. Not every cell needs to be filled.

Source DF SS MSS F
Treatment 4 1714.365 428.591 14.434

Answer. Error 26 772.022 29.693

Total 30 2486.387

(e) [2] Estimate the error variance (i.e., σ̂ 2 ).

Answer. An estimate for the error variance is given by σ̂ 2 = MSSerr = 29.693.

(f ) [4] Test the hypothesis that all treatment means are equal at the 10% level.
State the hypotheses, the test statistic and its reference distribution, the p-value or
critical value, and your conclusions.

Answer. We test the hypotheses

H0 : µ1 = . . . = µ5 , H1 : µi ̸= µj for some i ̸= j .

The test statistic is the F-statistic with value given in the ANOVA table. It has a
F4,26 distribution under H0 . The p-value is computed to be 2.484 × 10−6 . We reject
H0 at any reasonable significance level (including at the 10% level) and conclude
that at least two of the treatment means are different.

6
(g) [6] Construct simultaneous 90% CIs for the mean differences using Tukey’s
method. Pretend that you are computing all simultaneous CIs but show only the
first 3 (1 vs 2 ; 1 vs 3 ; 2 vs 3 ) in writing.

Answer. The 90% Tukey confidence intervals are given by


s
qTukey5,26 (0.9)
 
1 1
ȳi. − ȳj. ± √ MSSerr + .
2 ni nj
For the first three comparisons, we get

Comparison Lower Upper


1 vs 2 -14.156 1.356
1 vs 3 -11.121 7.521
2 vs 3 -5.741 14.941

All of the confidence intervals contain 0 and so none of the means between the first
three groups are significantly different.

6. [6] Under standard model assumptions of the one-way layout, the treatment and
error sums of squares are independent. This is largely due to two facts. The first
fact is that the total sum of squares has the decomposition

SStot = SStrt + SSerr .

The second fact is the following, which you will prove. Assume the common nota-
tions used in lectures.

Prove that cov(τ̂i , rij ) = 0 for all i, j.

Hint: work out the special case i = 1, j = 1, and comment on why the proof holds
for any i, j.

Answer. We show that Cov(τ̂i , rij ) = 0 for all i, j, or equivalently, that

Cov(ȳi. − ȳ.. , yij − ŷij ) = Cov(ȳi. − ȳ.. , yij − ȳi. ) = 0 .

As per the standard one-way layout, we assume that the k groups have the same
number of units n. By properties of covariance, we have

Cov(ȳi. − ȳ.. , yij − ȳi. ) = Cov(ȳi. , yij ) − Cov(ȳi. , ȳi. ) − Cov(ȳ.. , yij ) + Cov(ȳ.. , ȳi. )

= Cov(ȳi. , yij ) − Var(ȳi. ) − Cov(ȳ.. , yij ) + Cov(ȳ.. , ȳi. )


σ2
= Cov(ȳi. , yij ) − − Cov(ȳ.. , yij ) + Cov(ȳ.. , ȳi. ) .
n

7
By assumptions of the one-way layout, observations j and j ′ in group i are inde-
pendent and so

1 1 σ2
Cov(ȳi. , yij ) = Cov(yij , yij ) = Var(yij ) = .
n n n

Also by assumption of the one-way layout, groups i and i′ are independent of one
another, and so

1 1 σ2
Cov(ȳ.. , ȳi. ) = Cov(ȳi. , ȳi. ) = Var(ȳi. ) = ,
k k kn

and
1 1 σ2
Cov(ȳ.. , yij ) = Cov(yij , yij ) = Var(ȳi. ) = .
kn kn kn
Replacing the covariances with these simplified expressions in the above equation
gives us that Cov(τ̂i , rij ) = 0.

8
PAGE FOR ADDITIONAL SPACE OR SCRATCH WORK

9
PAGE FOR ADDITIONAL SPACE OR SCRATCH WORK

10

You might also like