2081 3

STA154 ยท 2081 ยท 10 marks

Question A software company tracks the number of hours its employees spend on coding (X) and the corresponding number of bugs they encounter during testing (Y). (a) Calculate the Pearson correlation coefficient. (b) Find the regression equation of Y on X. (c) Predict the number of bugs encountered i

Question

A software company tracks the number of hours its employees spend on coding (X) and the corresponding number of bugs they encounter during testing (Y).

$$\begin{array}{|c|cccccccccc|}\hline \text{Hours (X)} & 20 & 25 & 30 & 35 & 40 & 45 & 50 & 55 & 60 & 65 \ \hline \text{Bugs (Y)} & 5 & 7 & 8 & 12 & 15 & 13 & 17 & 18 & 20 & 25 \ \hline \end{array}$$

(a) Calculate the Pearson correlation coefficient.

(b) Find the regression equation of Y on X.

(c) Predict the number of bugs encountered if an employee spends 48 hours coding.

[10+0]

Basic StatisticsChapter 8: Correlation and Regression AnalysisKarl Pearson correlation coefficientNumerical: correlation and regression

Model Answer: Correlation and Regression Analysis

Given Data

X20253035404550556065
Y57812151317182025

$n = 10$, predict Y at $X = 48$.

Computation Table

XYXYXยฒYยฒ
20510040025
25717562549
30824090064
35124201225144
40156001600225
45135852025169
50178502500289
55189903025324
602012003600400
652516254225625

Totals:

  • $\sum X = 425$
  • $\sum Y = 140$
  • $\sum XY = 6785$
  • $\sum X^2 = 20125$
  • $\sum Y^2 = 2314$

Verification of totals: $\sum Y^2 = 25+49+64+144+225+169+289+324+400+625 = 2314$ โœ“

(a) Pearson Correlation Coefficient

$$r = \frac{n\sum XY - \sum X \sum Y}{\sqrt{[n\sum X^2 - (\sum X)^2][n\sum Y^2 - (\sum Y)^2]}}$$

Numerator: $$10(6785) - 425(140) = 67850 - 59500 = 8350$$

Denominator part 1: $$10(20125) - 425^2 = 201250 - 180625 = 20625$$

Denominator part 2: $$10(2314) - 140^2 = 23140 - 19600 = 3540$$

$$r = \frac{8350}{\sqrt{20625 \times 3540}} = \frac{8350}{\sqrt{73012500}} = \frac{8350}{8544.74} = 0.9772$$

$$\boxed{r \approx 0.977}$$

Watch the $X^2$ total: add the $X^2$ column carefully, since $\sum X^2 = 20125$ carries straight into $n\sum X^2 - (\sum X)^2 = 20625$ and into the product under the root, and a slip there changes $r$, $b$ and the prediction together.

Interpretation: Strong positive correlation; as coding hours increase, bugs tend to increase.

(b) Regression Equation of Y on X

$$b = \frac{n\sum XY - \sum X \sum Y}{n\sum X^2 - (\sum X)^2} = \frac{8350}{20625} = 0.40485$$

Means: $$\bar{X} = \frac{425}{10} = 42.5, \qquad \bar{Y} = \frac{140}{10} = 14$$

Intercept: $$a = \bar{Y} - b\bar{X} = 14 - 0.40485(42.5) = 14 - 17.2061 = -3.2061$$

$$\boxed{\hat{Y} = -3.2061 + 0.4048X}$$

(c) Prediction for X = 48

$$\hat{Y} = -3.2061 + 0.40485(48) = -3.2061 + 19.4328 = 16.2267$$

$$\boxed{\hat{Y} \approx 16.23 \approx 16 \text{ bugs}}$$

Conclusion: About 16 bugs are expected for 48 coding hours.

Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.