STAT 302/604 Summer 2025: Midterm
Instructor: Dr. Wei(Becky) Lin
Exam Date: Tuesday, June 24 2025, 6:30-8:10 PM at C9001
Midterm Solution
You have from 6:30pm until 8:10pm (100 minutes) to complete this exam.
Please read the instructions on this page carefully before beginning the exam.
Exam Instructions
• This exam consists of 5 QUESTIONS (all with multiple parts), printed on both sides of the
pages. Please make sure you do not accidentally skip any questions or parts of questions.
• You are allowed one page of aid sheet (one-sided, letter size) and a scientific calculator. No
other materials are permitted. Common critical values for hypothesis tests and confidence
intervals are provided on the back of the coverpage.
• Your solutions must be written in this exam booklet, in the space provided. Only
what is written in the provided spaces will be marked. Please write as legibly as
possible.
• Most questions in this midterm is designed so that you can answer many questions
and parts without getting previous questions/parts on the exam correct. If you get
stuck, consider moving on to the next part/question in order to maximize your score.
1
Question 1 (10 pts)
Match each description with the correct term from the list below. Please write only the letter
corresponding to the correct term in the underlined blank at the beginning of each statement.
A. Leverage
B. Normal Q-Q plot
C. Cook’s distance
D. Influential point
E. Standardized Residual
F. Adjusted R2
G. Prediction interval
H. Indicator (a.k.a Dummy) variable
I. Extrapolation
J. Least-Squares Method
Statements
1. Ans: J: The method used to determine the regression line that minimizes the sum of squared
residuals.
2. Ans: B: A diagnostic plot used to assess whether residuals follow a normal distribution.
3. Ans: H: A binary variable used to represent categories in a regression model.
4. Ans: F: The proportion of variation in the response variable that can be explained by the
model, adjusted for the number of predictors.
5. Ans: D: A data point that, if removed, significantly changes the regression model.
6. Ans: E: A residual (a.k.a internally Studentized residual) scaled by its estimated standard
deviation and further adjusted for the leverage of the observation.
7. Ans: I: Making predictions outside the range of observed data.
8. Ans: A: A data point with an extreme x-value (larger deviation from x̄) that may affect the
fitted model.
9. Ans: C: A diagnostic measure that combines leverage and residual size to evaluate influence.
10. Ans: G: A range used to predict the value of a new Y observation at a given x.
2
Question 2 (10 pts)
For a dataset on cars, we fit a simple linear regression model to predict Price using Mileage.
The summary output of the model is shown below, with some values intentionally left blank and
labeled A through D.
(a) [4 pts] Determine all the missing values labeled A through D in the output.
Solution:
• A = b/t-value = -0.58940/(-10.4) = 0.05667308 (1 mark)
• B = 0.0003 (1 mark), since p-value for the t-test and F-test are the same
• C = (t − test)2 = (−10.4)2 = 108.16 (1 mark).
• D = 1 (1 mark) since we have only one predictor in the model.
(b) [1 pt] Determine the correlation, r, between Price the Mileage in this data?
Solution:
√
• r = sign(b) 0.7945= −0.8913473 (1 mark,deduct 0.5 marks for wrong sign.)
(c) [1 pts] Identify the estimate of the error standard deviation, σ, from the R output?
Solution:
• σ̂ϵ = 7.17 (1 mark)
(d) [2 pts] What is the estimated least-square regression equation?
Solution:
[ = 71.09045 − 0.5894 · Mileage (1 mark)
• price
(e) [2 pts] Determine the residual for a car with Price = 43.5 and Mileage=50?
Solution:
[ = Ŷ = 71.09045 − 0.5894 · 50 = 41.62045 (1 mark)
• price
• Residual = Y - predicted Y = 43.5 - 41.62045 = 1.87955 (1 mark)
3
Question 3 (10 pts)
A multiple linear regression model is fit to predict the Weight (in grams) of perch using the predictors
Length (in cm) and Width (in cm). The ANOVA table of the model and diagnostic plots from R
are presented below.
## Analysis of Variance Table
##
## Response: Weight
##
Df Sum Sq Mean Sq F value
Pr(>F)
## Length
1 6118739 6118739 778.126 < 2.2e-16 ***
## Width
1 110593 110593 14.064 0.0004388 ***
## Residuals 53 416762
7863
## --## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
4
Normal Q−Q
0
−200
0
200
400
600
800
1000
3
2
54
1
100
54
1
52
0
52
−1
Standardized residuals
1
−100
Residuals
300
Residuals vs Fitted
−2
Fitted values
−1
0
1
2
Theoretical Quantiles
(a) [2 marks] Refer to the Residuals vs Fitted plot and the Normal Q-Q plot. What model
assumptions do these plots help you check, and what conclusions can you draw based on what
you see?
Solution:
• The residual plot is used to assess linearity and constant variance. There is a clear curved
pattern in the plot, suggesting that both assumptions are violated. (1 mark)
• The normal Q-Q plot is used to assess the normality of the residuals. We observed heavy
tails, so the normality condition is violated. (1 mark)
(b) [2 marks] Using the ANOVA output, compute the Sum of Squares for the Model (SSM)
and its corresponding degrees of freedom.
Solution:
• SSM = 6118739+110593 = 6229332 (1 mark)
• DF(SSM)= 2 (1 mark), since there are two predictors in the regression.
4
(c) [2 marks] Use the ANOVA output to compute R2 for the least squares regression model.
Solution:
• SST = SSM+SSE = 6229332+416762 = 1139228 . (1 mark)
• R2 = SSM/SST= 722466/1139228= 0.9373 = 93.73%
(d) [2 marks] Calculate the F-test value for testing the hypotheses:
H0 : βLength = βW idth = 0 vs Ha : at least one of them ̸= 0
Describe how would you get the p-value for this F-test?
Solution:
(SSM )
6229332/2
• F = SSM/df
SSE/df (SSE) = 416762/53 = 396.1 (1 mark).
• The p-value for this test is the upper tail area (0.5 marks) above 296.1 under F(df1=2,
df2=53). (0.5 marks).
(e) [2 marks] Now, the same model is re-fit using log-transformed variables, and the ANOVA
output is shown below:
## Analysis of Variance Table
##
## Response: log(Weight)
##
Df Sum Sq Mean Sq F value
Pr(>F)
## log(Length) 1 64.895 64.895 6967.95 < 2.2e-16 ***
## log(Width)
1 0.229
0.229
24.59 7.675e-06 ***
## Residuals
53 0.494
0.009
## --## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Assume the model meets all conditions. Is the log-transformed model better than the original?
Justify your answer using R2 .
Solution:
• SST = 64.895+0.229+0.494=65.618, R2 =1- SSE/SST= 1-0.494/65.618= 0.9925 (1 mark).
• Since R2 is higher for the log-transformed model, it explains more variability in Weight
and is therefore better than the original model.
5
Question 4 (10 pts)
A regression model was fit to the breakfast cereals data using X1 = Sugar and X2 = Fiber to predict
Y = Calories. The fitted model summary and the corresponding 95% confidence intervals for the
regression coefficients are presented below.
## Coefficients:
##
Estimate Std. Error t value Pr(>|t|)
## (Intercept) 109.3082
6.3913 17.103 < 2e-16 ***
## Sugar
1.0050
0.6546
1.535
0.134
## Fiber
-3.7442
0.8346 -4.486 8.31e-05 ***
## --## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 15.42 on 33 degrees of freedom
## Multiple R-squared: 0.5438, Adjusted R-squared: 0.5162
## F-statistic: 19.67 on 2 and 33 DF, p-value: 2.375e-06
##
2.5 %
97.5 %
## (Intercept) 96.3050363 122.311367
## Sugar
-0.3268206
2.336771
## Fiber
-5.4422197 -2.046082
(a) [1 pt] Write the regression equation implied by the model output?
Solution:
\ = 109.3082 + 1.0050 · Sugar − 3.7742 · Fiber.
• Calories
(b) [1.5 pts] What is the 95% Confidence interval for the slope of Sugar, βsugar , from the R
output? Write a sentence to interpret this interval.
Solution:
• From the R output, we get the 95% CI (0.5 marks) for βsugar : (-0.3268, 2.3367).
• We are 95% confident that calories are expected to change, on average, between -0.3268 and
2.3367, for each one-unit increase in sugar content (0.5 marks), holding Fiber constant (0.5
marks). Claim only that we are 95% confident that βsugar is in this interval, deduct 0.5 marks.
(c) [2 pts] Write a short sentence to interpret the regression coefficient of Fiber.
Solution:
• Among cereals with the same amount of sugar, or holding the sugar level fixed (1 mark),
calories decrease by an average of about 3.7 for each additional gram of fiber (1 mark).
6
(d) [2.5 pts] What are the null and alternative hypotheses for the ANOVA F-test with a value of
19.67 in the R output above? Is this F test significant at 0.1% significance level?
Solution:
• H0 : βSugar = βFiber = 0, or, none of the predictors (sugar and fiber) has a linear relationship
with the response variable, calories (1 mark).
• Ha : at least one of them ̸= 0, or, sugar and/or fiber is linearly related to the response variable
(1 mark).
• Yes (0.5 marks), this test is significant at 0.1% (0.5 marks) as the p-value is 2.375×10−6 which
is less than 0.1%.
(e) [1 pt] A student recorded the 95% confidence interval and 95% prediction interval for the
Original Oat Bran cereal, which contains 5 grams of sugar and 10 grams of fiber per serving.
Here’s his recording from R output:
##
fit
lwr
upr
## 1 76.89157 43.42465 110.3585
##
fit
lwr
upr
## 1 76.89157 65.21914 88.564
Which output corresponds to the prediction interval, and how do you know it is the prediction
interval?
Solution:
• The first interval (0.5 marks) is the prediction interval because it is wider (0.5 marks), ranging
from 43 to 110, while the second interval—the confidence interval—is narrower, ranging from
65 to 89.
(f) [2 pts] From the R summary output, could you determine the SSE (Sum of Square Error) and
the SST (Total Sum of Squares)?
Solution:
• MSE = σ̂ϵ = 15.42 =
p
SSE/33 ⇒ SSE =15.422 ∗ 33 = 7846.621 (1 Mark).
R2 = 1 −
SSE
7846.621
=1−
= 0.5438
SST
SST
• We there have SST = 7846.621/(1 − 0.5438) = 17199.96 (1 Mark).
7
Question 5 (10 marks)
A researcher investigates how weekly study hours affect final exam scores and whether the effect
differs between graduate and undergraduate students.
##
## Call:
## lm(formula = Score ~ Hours * Grad, data = exam_data)
##
## Residuals:
##
Min
1Q Median
3Q
Max
## -59.540 -18.697 -0.214 13.392 98.015
##
## Coefficients:
##
Estimate Std. Error t value Pr(>|t|)
## (Intercept) 54.1120
12.6780
4.268 4.63e-05 ***
## Hours
3.9969
0.6468
6.179 1.55e-08 ***
## Grad
8.1999
7.9396
1.033 0.304298
## Hours:Grad
-1.4127
0.3658 -3.862 0.000204 ***
## --## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 27.78 on 96 degrees of freedom
## Multiple R-squared: 0.5249, Adjusted R-squared:
0.51
## F-statistic: 35.35 on 3 and 96 DF, p-value: 1.77e-15
Where:
• Score: Final exam score
• Hours: Number of study hours per week.
• Grad: 1 = Graduate student, 0 = Undergraduate student (dummy variable)
Questions
(a) [1 pt] Write the regression equation implied by the model output?
Solution:
\ = 54.1120 + 3.9969 · Hours + 8.1999 · Grad − 1.4127 · Hours*Grad (1 mark)
• Score
(b) [1 pt] What is the estimated regression equation for undergraduate students?
Solution:
\ = 54.1120 + 3.9969 · Hours (1 mark)
• Score
(c) [1 pt] What is the estimated regression equation for graduate students?
Solution:
\ = (54.1120 + 8.1999) + (3.9969 − 1.4127) · Hours = 62.3119 + 2.5842 · Hours (1 mark)
• Score
8
(d) [2 pts] According to the model, what is the predicted score for a graduate student who
studies 10 hours per week?
Solution:
\ = 62.3119 + 2.5842 · 10(1 mark) = 88.1539 (1 mark)
• Score
(d) [2 pts] Interpret the coefficient of the interaction term, -1.4127, in the context of this model.
Solution:
• The interaction term of -1.4127 is the slope difference of Hours between graduate and
undergraduate students (1 mark), it indicates that, on average, each additional hour of study
is associated with a 1.4-point less in final exam score for graduate students compared to
undergraduates (1 mark).
(e) [2 pts] Report the test statistic value and p-value from the R output for this test: H0 :
βHours = βGrad = βHours:Grad = 0 vs Ha : at least one of them ̸= 0.
Solution:
• F-test= 35.35 (1 mark), P-value = 1.77e-15 = 1.77×10−15 (1 mark).
(g) [1 pt] Based on the output, which predictors are statistically significant at the 5% level?
Solution:
• Two predictors are statistically significant at the 5% level: Hours, Hours*Grad (1 mark)
9
END OF EXAM
10