Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
STAT 425 Exam 1 Study Problems
Exam problems are generally be shorter than homework problems and may involve short
answer conceptual questions, quick calculations and R code interpretation or debugging. It is
not a multiple choice exam, although some multiple choice questions are possible.
The sample problems below are to help you test yourself and practice solving.
Problems on the exam will generally have fewer parts to them than the ones
below. Do not expect the actual exam problems to be exactly like this set in
terms of range of coverage or length. Work on these various problems as a way
to solidify your understanding.
This is the unsolved version of the study problems. Solutions will be posted by Monday
morning.
1
1. Twenty chicks (baby chickens) were randomly assigned to receive one of two diets, A or B,
with 10 in each group. Consider the model
yi = β0 + β1xi + ei, i = 1, 2, 3, . . . , 20.
Here yi denotes the 14-day weight gain for the ith chick, and
xi =
−1, if chick i receives Diet A;1, if chick i receives Diet B.
The data are arranged so that Chick numbers 1 - 10 received Diet A and Chick numbers
11-20 received Diet B.
a) Calculate x¯ and Sxx for this design.
b) Show that βˆ1 the least squares estimate of β1 equals 12(y¯B − y¯A), where y¯A and y¯B are the
sample means for weight gain on Diet A and Diet B, respectively.
c) Suppose y¯A = 101.2, y¯B = 123.7 and
∑20
i=1(yi − yˆi)2 = 49.0. Calculate the value of the
t-statistic for testing the null hypothesis that β1 = 0.
2
2. We can rewrite the model from Problem 1 in matrix form as y = Xβ + e, where
y =
y1
y2
...
y19
y20
X =
1 −1
1 −1
... ...
1 1
1 1
β =
(
β0
β1
)
e =
e1
e2
...
e19
e20
a) Show that for this design the columns of X are orthogonal to each other.
b) Show that for this design cov(βˆ0, βˆ1) = 0.
c) Find the leverage of the first observation. Recall that hi = xTi (XTX)−1xi.
3
3. Consider a model of the form y = Xβ + e, where X is an n × p full rank matrix (its
columns are linearly independent), y and e are n × 1, and β is p × 1. The least squares
estimator βˆ solves the matrix equation
XT (y−Xβˆ) = 0.
Let yˆ = Xβˆ. Show or explain why each of the following equations holds, using the least
squares equation as a starting point:
a) yˆT (y− yˆ) = 0
b) yˆTy = yˆT yˆ
c) (y−Xβˆ)T (y−Xβˆ) = yTy− yˆTyˆ
d) RSS = ‖y− yˆ‖2 = yTy− βˆTXTXβˆ
e) Which, if any, of equations a), b), c), or d) says that the vector of residuals and vector of
fitted values are orthogonal to each other?
4
4. Consider a model of the form y = Xβ + e, where X is an n × p full rank matrix (its
columns are linearly independent), y and e are n× 1, and β is p× 1. Assume X is a fixed
(non-random) matrix, E(e) = 0, and cov(e) = σ2I. The least squares projection matrix H is
an n× n matrix, the “hat’ ’ matrix, of the form X(XTX)−1XT.
For each of the following statements, verify that it is true, or state why it is false:
a) yˆ = Xβˆ = Hy
b) βˆ = Hβ
c) HH = H
d) (I−H)X = 0
e) cov(y− yˆ) = σ2(I−H)
5
5. A study was conducted to compare antibiotic (drug) treatment with placebo (no drug) for
a certain disease. The variables are:
xi1 = Pretreatment condition score
xi2 =
1, Treated with drug;0, Treated with placebo (no drug).
yi = Post-Treatment condition score (condition after treatment)
The following model was fit using the lm function in R: yi = β0 + β1xi1 + β2xi2 + ei,
i = 1, 2, . . . , n, where the working assumptions are that the errors ei are independently
distributed as N(0, σ2). Some results are below.
##
## Call:
## lm(formula = PostTreatment ~ Pretreatment + Drug, data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.4110 -2.3897 -0.5214 1.6708 8.5890
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.4429 2.4216 -0.183 0.8562
## Pretreatment 0.9878 0.1611 6.132 1.5e-06 ***
## Drug -3.3896 1.6100 -2.105 0.0447 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.931 on 27 degrees of freedom
## Multiple R-squared: 0.6762, Adjusted R-squared: 0.6522
## F-statistic: 28.19 on 2 and 27 DF, p-value: 2.446e-07
a) What was the overall sample size, n?
b) In the model summary, a t value is reported for Drug. State the null hypothesis and
alternative hypothesis for this test, expressed in terms of the mathematical parameters (β0,
β1, β2, σ2). Is th enull hypothesis rejected at level 0.05?
6
c) At the end of the model summary, an F test result is reported. State the null hypothesis
and alternative hypothesis for this test, expressed in terms of the mathematical parameters
(β0, β1, β2, σ2). Is the null hypothesis rejected at level 0.05?
d) Based on the fitted model, estimate the expected post-treatment condition score for
a new patient with pre-treatment score of 10 if they receive the drug. Also compute the
post-treatment condition score if they received the placebo.
e) What does the $fit component in the output below tell us? Explain it briefly.
predict(mod1, newdata=data.frame(Pretreatment=12, Drug=0),
se.fit=TRUE, interval="prediction", level=0.90)
## $fit
## fit lwr upr
## 1 11.41096 4.383872 18.43804
##
## $se.fit
## [1] 1.251574
##
## $df
## [1] 27
##
## $residual.scale
## [1] 3.931175
7
6. This problem considers the same data and model as in Problem 5.
a) A scatter plot of studentized residuals versus fitted values is shown below.
0 5 10 15 20
−
1
0
1
2
fitted(mod1)
rs
tu
de
nt
(m
od
1)
There is a hint of increasing vertical spread in the graph as we move from left to right. If that
effect is real, what does it suggest about the model assumptions we have made? Describe
briefly.
b) What are the values being graphed below, and what do they tell us?
library(faraway)
halfnorm(influence(mod1)$hat)
8
0.0 0.5 1.0 1.5 2.0
0.
00
0.
05
0.
10
0.
15
0.
20
Half−normal quantiles
So
rte
d
Da
ta
17
25
c) What are the values being graphed below, and what do they tell us?
halfnorm(cooks.distance(mod1))
0.0 0.5 1.0 1.5 2.0
0.
00
0.
05
0.
10
0.
15
0.
20
Half−normal quantiles
So
rte
d
Da
ta
23
30
9
7. Continuing with the data and variables defined in Problem 5, consider the following R
code and results:
library(MASS)
lambdas = boxcox(PostTreatment+1 ~ Pretreatment+Drug, data=df)
−2 −1 0 1 2
−
10
0
−
80
−
60
−
40
λ
lo
g−
Li
ke
lih
oo
d
95%
attributes(lambdas)
## $names
## [1] "x" "y"
lambdas$x[lambdas$y==max(lambdas$y)]
## [1] 0.4242424
a) Write out the class of regression models being fit here, expressed in terms of our original
variables xi1, xi2, yi, ei, and the parameters β0, β1, β2, σ2, and λ.
b) What is the estimated numerical value of λ? Also, give an approximate 95% confidence
interval for λ.
10
c) Do these results indicate that we should modify the linear model we fit in Problem 5? If
so what do you recommend?
11
8. Consider a model of the form yi = β0 + β1xi + xiei, 1, 2, . . . , n, where yi is the observed
response, the xi are observed, positive (>0), nonrandom values of an explanatory variable,
and the errors ei have mean zero, are uncorrelated and have constant variance σ2.
a) Find expressions for the expected value and variance of yi, i = 1, 2, . . . , n.
b) Find Cov(yi, yj) for i 6= j.
c) The optimal weighted least squares estimator for (β0, β1) is obtained by minimizing a
criterion of the form
RSSw(β0, β1) =
n∑
i=1
wi(yi − β0 − β1xi)2
as long as we chose the weights correctly. What are the optimal weights wi, i.e., what should
we plug in for wi?
d) Consider a constructed response variable zi = yi/xi. Show that zi follows a homoscedastic
(constant variance) linear model with a transformed explanatory variable, and write out the
form of the model.
e) Write out the form of the ordinary least squares RSS(β0, β1) for the model in d), and
show that it reduces to RSSw(β0, β1) in c) with the optimal of weights wi.