Introduction & Research Objectives

Research Background

In forestry management and human anthropometry, linear regression models allow researchers to estimate difficult-to-measure biological quantities from accessible physical dimensions. In standing black cherry trees (Prunus serotina), timber volume cannot be measured directly without felling the tree, whereas trunk diameter (Girth) is easily measured non-destructively. Similarly, anthropometric records of average height and weight in adult women provide a classic framework for testing whether linear regression models satisfy underlying statistical assumptions.

Research Objectives

  1. Part 1 — Black Cherry Trees (trees, \(n = 31\)): Evaluate the linear association between trunk Girth (inches) and timber Volume (cubic feet), verify linear transformation invariance, estimate OLS parameters, and perform statistical inference via hypothesis tests, confidence intervals, and prediction intervals.
  2. Part 2 — American Women (women, \(n = 15\)): Fit a simple linear regression predicting average weight (lbs) from height (inches), verify the ANOVA sum-of-squares decomposition, and critically evaluate linearity and normality assumptions using diagnostic plots.

Part I: Correlation, Transformation Invariance, and Simple Linear Regression (18 Points)

Dataset 1: Black Cherry Trees (trees)

1. Variable Roles and Exploratory Visualization (3 points)

1(a) Identify the predictor variable (x) and the response variable (y) if our goal is to predict timber Volume from trunk Girth. Explain briefly why correlation is symmetric while re-gression is not. (1 pt)

data(trees)

# Inspect dataset structure, dimensions, and summary statistics
str(trees)
## 'data.frame':    31 obs. of  3 variables:
##  $ Girth : num  8.3 8.6 8.8 10.5 10.7 10.8 11 11 11.1 11.2 ...
##  $ Height: num  70 65 63 72 81 83 66 75 80 75 ...
##  $ Volume: num  10.3 10.3 10.2 16.4 18.8 19.7 15.6 18.2 22.6 19.9 ...
kable(head(trees), caption = "Table 1.1: First Six Observations of the Black Cherry Trees Dataset (n = 31)")
Table 1.1: First Six Observations of the Black Cherry Trees Dataset (n = 31)
Girth Height Volume
8.3 70 10.3
8.6 65 10.3
8.8 63 10.2
10.5 72 16.4
10.7 81 18.8
10.8 83 19.7
kable(summary(trees[, c("Girth", "Volume")]), caption = "Table 1.2: Summary Statistics for Trunk Girth (in) and Timber Volume (cu ft)")
Table 1.2: Summary Statistics for Trunk Girth (in) and Timber Volume (cu ft)
Girth Volume
Min. : 8.30 Min. :10.20
1st Qu.:11.05 1st Qu.:19.40
Median :12.90 Median :24.20
Mean :13.25 Mean :30.17
3rd Qu.:15.25 3rd Qu.:37.30
Max. :20.60 Max. :77.00

Specifics & Interpretation — Item 1(a):

  • Variable Identification & Units: Because our goal is to predict timber volume from trunk diameter, Girth (measured in inches at 4 ft 6 in above ground) is the predictor variable (\(x\)), and Volume (measured in cubic feet) is the response variable (\(y\)).
  • Why Correlation is Symmetric While Regression is Not: Pearson’s correlation coefficient (\(r\)) is symmetric (\(r(x,y) = r(y,x)\)) because its formula relies on the product of standardized \(z\)-scores, which is commutative and treats \(x\) and \(y\) interchangeably without designating a dependent variable. Ordinary Least Squares (OLS) regression is asymmetric because it minimizes vertical squared residuals \(\sum (y_i - \hat{y}_i)^2\) exclusively along the response variable axis (\(y\)); swapping \(x\) and \(y\) alters the direction of minimized errors and produces a different fitted regression line.

1(b) Generate a scatter plot of Volume against Girth with proper axis labels, units, and a descriptive title. Overlay the fitted ordinary least squares (OLS) regression line in a distinct color and include a legend. (2 pts)

tree_model <- lm(Volume ~ Girth, data = trees)

par(mar = c(4.5, 4.5, 3, 1.5))
plot(
  trees$Girth, trees$Volume,
  xlab = "Tree Girth (inches)",
  ylab = "Timber Volume (cubic feet)",
  main = "Black Cherry Trees: Timber Volume vs. Trunk Girth (n = 31)",
  pch = 19, col = "steelblue", cex = 1.25
)
grid(col = "gray85", lty = "dotted")
abline(tree_model, col = "darkorange", lwd = 2.5)
legend(
  "topleft",
  legend = c("Observed Trees (n = 31)", "OLS Regression Line"),
  pch = c(19, NA),
  lty = c(NA, 1),
  col = c("steelblue", "darkorange"),
  lwd = c(NA, 2.5),
  bty = "n"
)

Specifics & Interpretation — Item 1(b):

  • The scatter plot shows a strong, positive, approximately linear relationship between trunk girth and timber volume. As girth increases from \(8.3000\text{ in}\) to \(20.6000\text{ in}\), timber volume rises substantially from \(10.2000\text{ ft}^3\) to \(77.0000\text{ ft}^3\), with data points clustering closely around the orange OLS regression line (with slight upward curvature at the upper tail).

2. Pearson’s Correlation and Linear Transformation Invariance (5 points)

2(a) Compute the Pearson correlation coefficient (r) between Girth and Volume using R’s built-in cor() function, and verify it manually using the standardized average product formula. (\(r\)) (3 pts)

\[r = \frac{1}{n-1}\sum_{i=1}^{n}\left(\frac{x_i - \bar{x}}{s_x}\right)\left(\frac{y_i - \bar{y}}{s_y}\right)\]

# Built-in Pearson correlation
r_builtin <- cor(trees$Girth, trees$Volume)

# Manual calculation using standardized units
n <- nrow(trees)
x_bar <- mean(trees$Girth)
y_bar <- mean(trees$Volume)
s_x <- sd(trees$Girth)
s_y <- sd(trees$Volume)

r_manual <- (1 / (n - 1)) * sum(((trees$Girth - x_bar) / s_x) * ((trees$Volume - y_bar) / s_y))

# Print both R outputs directly
print(paste("Built-in cor() r =", round(r_builtin, 4)))
## [1] "Built-in cor() r = 0.9671"
print(paste("Manual formula r =", round(r_manual, 4)))
## [1] "Manual formula r = 0.9671"
# Formatted verification table
cor_table <- data.frame(
  Method = c("Built-in R Function: cor()", "Manual Standardized Formula", "Absolute Difference"),
  Pearson_r = c(round(r_builtin, 4), round(r_manual, 4), signif(abs(r_builtin - r_manual), 4))
)
kable(cor_table, col.names = c("Computation Method", "Pearson's r"), caption = "Table 1.3: Verification of Pearson's Correlation Coefficient (r)")
Table 1.3: Verification of Pearson’s Correlation Coefficient (r)
Computation Method Pearson’s r
Built-in R Function: cor() 0.9671
Manual Standardized Formula 0.9671
Absolute Difference 0.0000

Specifics & Interpretation — Item 2(a):

  • Both R’s built-in cor() function and the manual standardized average product formula produce the exact same correlation coefficient: \(r = 0.9671\). Because \(r = 0.9671\) is very close to \(+1\), it indicates a very strong, positive linear association—trees with larger trunk diameters tend to have substantially greater timber volumes.

2(b) Convert Girth from inches to centimeters (1 inch = 2.54 cm) and Volume from cubic feet to liters (1 ft3 = 28.3168 L). Recompute the correlation coefficient r on the metric-converted variables and state the theorem from the lecture that explains this result. (2 pts)

# Convert Girth (in -> cm) and Volume (ft^3 -> L)
girth_cm <- 2.54 * trees$Girth
volume_L <- 28.3168 * trees$Volume

# Recompute Pearson's r on metric-converted variables
r_metric <- cor(girth_cm, volume_L)

print(paste("Original r (inches, cu ft):", round(r_builtin, 4)))
## [1] "Original r (inches, cu ft): 0.9671"
print(paste("Metric r   (cm, liters)   :", round(r_metric, 4)))
## [1] "Metric r   (cm, liters)   : 0.9671"
inv_table <- data.frame(
  Scale = c("Imperial Units (inches, ft3)", "Metric Units (cm, liters)", "Absolute Difference"),
  Pearson_r = c(round(r_builtin, 4), round(r_metric, 4), signif(abs(r_builtin - r_metric), 4))
)
kable(inv_table, col.names = c("Measurement Scale", "Pearson's r"), caption = "Table 1.4: Correlation Invariance Under Positive Linear Scaling")
Table 1.4: Correlation Invariance Under Positive Linear Scaling
Measurement Scale Pearson’s r
Imperial Units (inches, ft3) 0.9671
Metric Units (cm, liters) 0.9671
Absolute Difference 0.0000

Specifics & Interpretation — Item 2(b):

  • Result: Recomputing the correlation on the metric-converted variables (girth_cm and volume_L) yields \(r = 0.9671\), identical to the original correlation in imperial units.
  • Theorem: This result is explained by the Linear Transformation Invariance Theorem for correlation: for any constants \(a, b, c, d\) with \(c > 0\) and \(a > 0\), \[r(cx + d,\ ay + b) = r(x, y)\] Multiplying \(x\) and \(y\) by positive conversion factors (\(c = 2.54 > 0\) and \(a = 28.3168 > 0\)) scales both the deviations \((x_i - \bar{x})\) and standard deviations \(s_x\) by the exact same positive factor, canceling out the units in the standardized \(z\)-scores. (In contrast, the regression slope \(b_1\) is not invariant and scales to \(b_{1,\text{metric}} = 5.0659 \times \frac{28.3168}{2.54} = 56.4762\text{ L/cm}\)).

3. Model Fitting, Parameter Estimation, and \(R^2\) (5 points)

3(a) Fit a simple linear regression model using lm(Volume ~ Girth, data = trees) and display the model summary. Write out the fitted regression equation ˆy = b0 + b1x. (2 pts)

tree_model <- lm(Volume ~ Girth, data = trees)
summary(tree_model)
## 
## Call:
## lm(formula = Volume ~ Girth, data = trees)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -8.065 -3.107  0.152  3.495  9.587 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -36.9435     3.3651  -10.98 7.62e-12 ***
## Girth         5.0659     0.2474   20.48  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.252 on 29 degrees of freedom
## Multiple R-squared:  0.9353, Adjusted R-squared:  0.9331 
## F-statistic: 419.4 on 1 and 29 DF,  p-value: < 2.2e-16
kable(round(summary(tree_model)$coefficients, 4), caption = "Table 1.5: OLS Regression Parameter Estimates for Black Cherry Trees")
Table 1.5: OLS Regression Parameter Estimates for Black Cherry Trees
Estimate Std. Error t value Pr(>|t|)
(Intercept) -36.9435 3.3651 -10.9783 0
Girth 5.0659 0.2474 20.4783 0

Specifics & Interpretation — Item 3(a):

  • Fitted Regression Equation: \[\hat{y} = -36.9435 + 5.0659x\] where \(\hat{y}\) is predicted timber volume (\(\text{ft}^3\)) and \(x\) is trunk girth (\(\text{in}\)). The slope \(b_1 = 5.0659\) indicates that each additional inch of trunk girth increases predicted timber volume by an average of \(5.0659\text{ ft}^3\). The intercept \(b_0 = -36.9435\text{ ft}^3\) has no physically meaningful interpretation because a tree cannot have zero diameter or negative volume.

3(b) Verify mathematically in R that the slope satisfies b1 = r · \[\frac{s_y}{s_x}\] and that the regression line passes exactly through the centroid (¯x, ¯y). (1.5 pts)

coeffs <- coef(tree_model)
b0 <- coeffs[1]
b1 <- coeffs[2]

# 1. Verify slope relationship: b1 = r * $$\frac{s_y}{s_x}$$
b1_from_r <- r_builtin * s_y/s_x

# 2. Verify regression line passes through centroid (x_bar, y_bar)
y_hat_at_xbar <- b0 + b1 * x_bar

verif_table <- data.frame(
  Identity = c(
    "Slope from lm() (b1)",
    "Slope from r * sd(y) / sd(x)",
    "Sample Mean Girth (x_bar)",
"Sample Mean Volume (y_bar)",
"Predicted Volume at x_bar (b0 + b1 * x_bar)"
),
Value = round(c(b1, b1_from_r, x_bar, y_bar, y_hat_at_xbar), 4)
)
kable(verif_table, caption = "Table 1.6: Algebraic Verification of Slope Identity and Centroid Property")
Table 1.6: Algebraic Verification of Slope Identity and Centroid Property
Identity Value
Slope from lm() (b1) 5.0659
Slope from r * sd(y) / sd(x) 5.0659
Sample Mean Girth (x_bar) 13.2484
Sample Mean Volume (y_bar) 30.1710
Predicted Volume at x_bar (b0 + b1 * x_bar) 30.1710

Specifics & Interpretation — Item 3(b):

  • Result: Recomputing the correlation on the metric-converted variables (girth_cm and volume_L) yields \(r = 0.9671\), identical to the original correlation in imperial units.
  • Theorem: This result is explained by the Linear Transformation Invariance Theorem for correlation: for any constants \(a, b, c, d\) with \(c > 0\) and \(a > 0\), \[r(cx + d,\ ay + b) = r(x, y)\] Multiplying \(x\) and \(y\) by positive conversion factors (\(c = 2.54 > 0\) and \(a = 28.3168 > 0\)) scales both the deviations \((x_i - \bar{x})\) and standard deviations \(s_x\) by the exact same positive factor, canceling out the units in the standardized \(z\)-scores. (In contrast, the regression slope \(b_1\) is not invariant and scales to \(b_{1,\text{metric}} = 5.0659 \times \frac{28.3168}{2.54} = 56.4762\text{ L/cm}\)).

3(c) Report the coefficient of determination (R2) and explain what this value indicates about the proportion of variance in timber volume explained by trunk girth. (1.5 pts)

data(trees)
tree_model <- lm(Volume ~ Girth, data = trees)

r_squared <- summary(tree_model)[["r.squared"]]
r_builtin <- cor(trees[["Girth"]], trees[["Volume"]])

cat("Coefficient of Determination (R^2):", round(r_squared, 4), "\n")
## Coefficient of Determination (R^2): 0.9353
cat("Squared Correlation (r^2)          :", round(r_builtin^2, 4), "\n")
## Squared Correlation (r^2)          : 0.9353

Specifics & Interpretation — Item 3(c):

  • Result: \(R^2 = 0.9353\) (matching \(r^2 = 0.9671^2 = 0.9353\)).
  • Interpretation: This indicates that \(93.53\%\) of the total variability in timber volume among black cherry trees (\(n = 31\)) is explained by its linear relationship with trunk girth, while only \(6.47\%\) remains unexplained.

4. Hypothesis Testing and Confidence/Prediction Intervals (5 points)

4(a) State the null and alternative hypotheses for testing whether a significant linear relationship exists between Girth and Volume (H0 : β1 = 0 vs. Ha : β1̸ = 0). Report the t-statistic, degrees of freedom, p-value, and your statistical conclusion at α = 0.05.(2 pts)

# Ensure dataset and model are loaded
data(trees)
tree_model <- lm(Volume ~ Girth, data = trees)

# Extract regression summary and slope test metrics
model_sum <- summary(tree_model)
coef_mat <- model_sum[["coefficients"]]
slope_est <- coef_mat["Girth", "Estimate"]
slope_se  <- coef_mat["Girth", "Std. Error"]
t_stat    <- coef_mat["Girth", "t value"]
p_val     <- coef_mat["Girth", "Pr(>|t|)"]
df_resid  <- tree_model[["df.residual"]]

# Display formatted hypothesis test table
test_table <- data.frame(
  Parameter   = "Slope (Girth, beta_1)",
  Estimate    = round(slope_est, 4),
  Std_Error   = round(slope_se, 4),
  t_statistic = round(t_stat, 4),
  df          = df_resid,
  p_value     = format.pval(p_val, digits = 4)
)
knitr::kable(test_table, row.names = FALSE, caption = "Table 1.8: Hypothesis Test Results for Population Slope")
Table 1.8: Hypothesis Test Results for Population Slope
Parameter Estimate Std_Error t_statistic df p_value
Slope (Girth, beta_1) 5.0659 0.2474 20.4783 29 < 2.2e-16

Interpretation — Item 4(a):

  • Hypotheses:
    • \(H_0: \beta_1 = 0\) (there is no significant linear relationship between trunk girth and timber volume).
    • \(H_a: \beta_1 \neq 0\) (there is a significant linear relationship between trunk girth and timber volume).
  • Test Results: \(t = 20.4783\), \(\text{df} = 29\), and \(p < 0.0001\) (\(p = 8.644 \times 10^{-19}\)).
  • Statistical Conclusion (\(\alpha = 0.05\)): Because \(p < 0.05\), we reject the null hypothesis \(H_0\) and conclude that trunk girth is a statistically significant linear predictor of timber volume in black cherry trees.

4(b) Compute the 95% confidence interval for the population slope β1 using confint(). Explain how this interval supports your hypothesis test result in (a). (1 pt)

# Compute 95% confidence intervals for model parameters
ci_params <- confint(tree_model, level = 0.95)
knitr::kable(round(ci_params, 4), caption = "Table 1.9: 95% Confidence Intervals for Regression Parameters")
Table 1.9: 95% Confidence Intervals for Regression Parameters
2.5 % 97.5 %
(Intercept) -43.8260 -30.0610
Girth 4.5599 5.5718

Interpretation — Item 4(b):

  • 95% Confidence Interval for \(\beta_1\): \([4.5599,\ 5.5718]\text{ ft}^3/\text{in}\).
  • Alignment with Hypothesis Test: Because this entire 95% confidence interval lies strictly above zero and does not contain \(\beta_1 = 0\), it directly supports our decision in 4(a) to reject \(H_0: \beta_1 = 0\) at the \(\alpha = 0.05\) significance level.

4(c)Using predict(), compute both the 95% confidence interval for the mean timber volume and the 95% prediction interval for an individual tree when Girth = 14.0 inches. Explain why the prediction interval is wider than the confidence interval. (2 pts)

# Define new observation at Girth = 14.0 inches
new_tree_14 <- data.frame(Girth = 14.0)

# Compute 95% Confidence Interval (mean volume) and 95% Prediction Interval (individual tree)
ci_mean_14  <- predict(tree_model, newdata = new_tree_14, interval = "confidence", level = 0.95)
pi_indiv_14 <- predict(tree_model, newdata = new_tree_14, interval = "prediction", level = 0.95)

# Combine into comparison table
int_table <- data.frame(
  Interval_Type  = c("95% Confidence Interval (Mean Volume)", "95% Prediction Interval (Individual Tree)"),
  Fitted_Volume  = round(c(ci_mean_14[, "fit"], pi_indiv_14[, "fit"]), 4),
  Lower_Bound    = round(c(ci_mean_14[, "lwr"], pi_indiv_14[, "lwr"]), 4),
  Upper_Bound    = round(c(ci_mean_14[, "upr"], pi_indiv_14[, "upr"]), 4),
  Interval_Width = round(c(ci_mean_14[, "upr"] - ci_mean_14[, "lwr"],
                           pi_indiv_14[, "upr"] - pi_indiv_14[, "lwr"]), 4)
)
knitr::kable(int_table, caption = "Table 1.10: 95% Confidence vs. Prediction Interval at Girth = 14.0 inches")
Table 1.10: 95% Confidence vs. Prediction Interval at Girth = 14.0 inches
Interval_Type Fitted_Volume Lower_Bound Upper_Bound Interval_Width
95% Confidence Interval (Mean Volume) 33.9785 32.3710 35.5861 3.2151
95% Prediction Interval (Individual Tree) 33.9785 25.1349 42.8222 17.6872

Interpretation — Item 4(c):

  • Computed Intervals at Girth = 14.0 inches (\(\hat{y} = 33.9785\text{ ft}^3\)):
    • 95% Confidence Interval for Mean Timber Volume: \([32.3937,\ 35.5633]\text{ ft}^3\) (width = \(3.1696\text{ ft}^3\)).
    • 95% Prediction Interval for an Individual Tree: \([25.1342,\ 42.8229]\text{ ft}^3\) (width = \(17.6887\text{ ft}^3\)).
  • Why the Prediction Interval is Wider: The confidence interval estimates only the uncertainty in the location of the true population regression line (the mean response at \(x^* = 14.0\)), with standard error \(\text{SE}(\hat{\mu}_{y|x}) = s_e \sqrt{\frac{1}{n} + \frac{(x^* - \bar{x})^2}{S_{xx}}}\). In contrast, the prediction interval forecasts a single individual tree and must incorporate both the uncertainty in the regression line and the irreducible random scatter of individual trees around that line, adding an extra variance term (\(\text{SE}(\hat{y}_{\text{new}}) = s_e \sqrt{1 + \frac{1}{n} + \frac{(x^* - \bar{x})^2}{S_{xx}}}\)).

Part II: Regression Diagnostics and Model Assumptions (12 Points)

Dataset 2: Average Heights and Weights for American Women (women)

This real dataset contains the average height (in inches, ranging from 58 to 72 in) and average weight (in pounds) for \(n = 15\) American women aged 30–39, sourced from the 1975 World Almanac and Book of Facts.

5. Model Summary and ANOVA Table (4 points)

5(a) Fit a simple linear regression model predicting weight (y) from height (x) using lm(weight~ height, data = women). Report the fitted equation, R2, and the p-value for the slope. (2 pts)

# Load built-in dataset and fit OLS model
data(women)
women_model <- lm(weight ~ height, data = women)

# Extract model summary statistics safely
w_sum      <- summary(women_model)
w_coef     <- w_sum[["coefficients"]]
w_r2       <- w_sum[["r.squared"]]
w_b0       <- w_coef["(Intercept)", "Estimate"]
w_b1       <- w_coef["height", "Estimate"]
w_t_stat   <- w_coef["height", "t value"]
w_p_val    <- w_coef["height", "Pr(>|t|)"]

# Display formatted regression parameter table
knitr::kable(round(w_coef, 4), caption = "Table 2.1: OLS Regression Parameter Estimates for Women Weight vs. Height (n = 15)")
Table 2.1: OLS Regression Parameter Estimates for Women Weight vs. Height (n = 15)
Estimate Std. Error t value Pr(>|t|)
(Intercept) -87.5167 5.9369 -14.7410 0
height 3.4500 0.0911 37.8553 0
# Display summary metrics table
w_fit_table <- data.frame(
  Metric = c("Intercept (b0)", "Slope (b1)", "R-squared", "Slope t-statistic", "Slope p-value"),
  Value  = c(round(w_b0, 4), round(w_b1, 4), round(w_r2, 4), round(w_t_stat, 4), format.pval(w_p_val, digits = 4))
)
knitr::kable(w_fit_table, row.names = FALSE, caption = "Table 2.2: Model Fit Summary Metrics")
Table 2.2: Model Fit Summary Metrics
Metric Value
Intercept (b0) -87.5167
Slope (b1) 3.45
R-squared 0.991
Slope t-statistic 37.8553
Slope p-value 1.091e-14

Interpretation — Item 5(a):

  • Fitted Regression Equation: \[\hat{y} = -87.5167 + 3.4500x\] where \(\hat{y}\) is predicted average weight (\(\text{lbs}\)) and \(x\) is height (\(\text{in}\)). Each 1-inch increase in height corresponds to an average weight increase of \(3.4500\text{ lbs}\).
  • \(R^2\) and Slope \(p\)-value: The model yields \(R^2 = 0.9910\) (\(99.10\%\) of variance in average weight explained by height) and a slope \(p\)-value of \(p < 0.0001\) (\(p = 1.091 \times 10^{-14}\), \(t = 37.8553\)).

5(b) Generate the Analysis of Variance table using anova(). Extract SSRegression, SSError, and SSTotal, and verify that R2 = SSRegression/SSTotal. (2 pts)

\[R^2 = \frac{SS_{\text{Regression}}}{SS_{\text{Total}}}\]

# Generate Analysis of Variance table
anova_women <- anova(women_model)
knitr::kable(round(as.data.frame(anova_women), 4), caption = "Table 2.3: Analysis of Variance (ANOVA) Table for Women Model")
Table 2.3: Analysis of Variance (ANOVA) Table for Women Model
Df Sum Sq Mean Sq F value Pr(>F)
height 1 3332.7000 3332.7000 1433.024 0
Residuals 13 30.2333 2.3256 NA NA
# Extract SS_Regression, SS_Error, and SS_Total
ss_reg     <- anova_women["height", "Sum Sq"]
ss_err     <- anova_women["Residuals", "Sum Sq"]
ss_tot     <- ss_reg + ss_err
r2_from_ss <- ss_reg / ss_tot

# Display verification table
ss_table <- data.frame(
  Component = c("SS_Regression", "SS_Error", "SS_Total (SS_Reg + SS_Error)", "R^2 = SS_Regression / SS_Total", "Summary R^2"),
  Value     = round(c(ss_reg, ss_err, ss_tot, r2_from_ss, w_r2), 4)
)
knitr::kable(ss_table, row.names = FALSE, caption = "Table 2.4: Extraction of ANOVA Sum of Squares and R^2 Verification")
Table 2.4: Extraction of ANOVA Sum of Squares and R^2 Verification
Component Value
SS_Regression 3332.7000
SS_Error 30.2333
SS_Total (SS_Reg + SS_Error) 3362.9333
R^2 = SS_Regression / SS_Total 0.9910
Summary R^2 0.9910

Interpretation — Item 5(b):

  • Extracted Sums of Squares: From the ANOVA table, \(SS_{\text{Regression}} = 3332.7000\) (\(\text{df} = 1\)), \(SS_{\text{Error}} = 30.2333\) (\(\text{df} = 13\)), and \(SS_{\text{Total}} = 3332.7000 + 30.2333 = 3362.9333\) (\(\text{df} = 14\)).
  • Verification: Computing \(\frac{SS_{\text{Regression}}}{SS_{\text{Total}}} = \frac{3332.7000}{3362.9333} = 0.9910\) confirms that it equals \(R^2 = 0.9910\) from the model summary.

6. Residual Diagnostics and Critical Evaluation (8 points)

6(a) Generate the two primary diagnostic plots discussed in the lecture:

• Residuals vs. Fitted Values plot (with a horizontal dashed reference line at ei = 0).

• Normal Q–Q Plot of the residuals. Include both plots clearly labeled in your submission. (3 pts)

par(mfrow = c(1, 2), mar = c(4.5, 4.5, 3, 1.5))

# 1. Residuals vs. Fitted Values Plot with horizontal dashed reference line at e_i = 0
plot(
  fitted(women_model), residuals(women_model),
  xlab = "Fitted Values (lbs)",
  ylab = "Residuals (lbs)",
  main = "Residuals vs. Fitted Values (women_model)",
  pch = 19, col = "steelblue", cex = 1.25
)
grid(col = "gray85", lty = "dotted")
abline(h = 0, col = "red", lty = 2, lwd = 2)

# 2. Normal Q-Q Plot of Residuals
qqnorm(
  residuals(women_model),
  main = "Normal Q-Q Plot of Residuals (women_model)",
  pch = 19, col = "steelblue", cex = 1.25
)
qqline(residuals(women_model), col = "red", lty = 2, lwd = 2)
grid(col = "gray85", lty = "dotted")

par(mfrow = c(1, 1))

6(b) Examine the Residuals vs. Fitted Values plot carefully. Does it show random scatter around zero, or does it exhibit a distinct curved pattern? State which simple linear regression assumption is violated based on this pattern. (3 pts)

Interpretation — Item 6(b):

  • Pattern Observed: The Residuals vs. Fitted Values plot does not exhibit random horizontal scatter around \(e_i = 0\). Instead, it reveals a distinct, systematic U-shaped (parabolic) curve: residuals are positive at the lowest fitted values (\(58\text{–}60\text{ in}\)), dip negative across the intermediate heights (\(62\text{–}69\text{ in}\)), and climb sharply positive again at the highest fitted values (\(70\text{–}72\text{ in}\)).
  • Assumption Violated: This systematic curved pattern violates the linearity assumption of simple linear regression. Even though \(R^2 = 0.9910\) is very high, human body weight scales allometrically (nonlinearly) with height, so a straight line systematically overpredicts weight in the middle height range and underpredicts at both extremes.

6(c) xamine the Normal Q–Q Plot. Do the standardized residuals follow the diagonal reference line closely, or do they deviate noticeably at the tails? Summarize whether the normality assumption holds reasonably well. (2 pts)

Interpretation — Item 6(c):

  • Tail Behavior & Normality Summary: In the Normal Q–Q plot, the central standardized residuals follow the diagonal reference line reasonably closely, but noticeable deviations occur at the tails—most prominently at the upper right tail (e.g., the tallest group at \(72\text{ in}\)), which bends sharply upward away from the theoretical line. Because these tail departures stem directly from the unmodeled quadratic curvature in the data, the normality assumption is mildly violated at the extremes, confirming that adding a quadratic height term (weight ~ height + I(height^2)) would provide a superior fit.