Statistics 2

In-Class Exercise 8

Yu-You Liou

Shih Chien University

2026-09-16

Data for Questions 1 to 3

Use the advertising and sales data from Exercise 6, and the fitted model model <- lm(sales ~ ads).

Question 1

Coefficient of Determination

  1. Compute r^2 by squaring the value of cor(), and confirm it with summary(model)$r.squared.
  2. State the percentage of the variation in sales that is explained by advertising expenditure.
  3. State the percentage that remains unexplained, and give one example of a variable that might account for it.

Question 2

Standard Error of the Estimate

The standard error of the estimate is

s_{est}=\sqrt{\frac{\sum(y-y')^2}{n-2}}

  1. Compute it in R with resid() and sqrt().
  2. Confirm your answer with summary(model)$sigma.
  3. Explain in one sentence what s_{est} measures.

Question 3

Residual Analysis

  1. Compute the residuals with resid() and verify that they sum to approximately zero.
  2. Plot the residuals against the fitted values with ggplot() and geom_point(), and add a horizontal line at zero with geom_hline().
  3. Does the plot show any pattern? State in one sentence whether the linear model appears adequate.