Statistics I · Unit 7 · 7 hrs
Correlation and Linear Regression
Exam-focused notes for Correlation and Linear Regression (Statistics I, STA169): what the TU syllabus asks and how it has actually been tested, with 9 solved past questions from this unit.
Correlation and Linear Regression in short
Many quantities of interest come in pairs, hours studied and marks scored, CPU load and response time, and this chapter measures how strongly two such variables move together, and builds an equation to predict one from the other.
What this unit covers
- Bivariate data
- Bivariate frequency distribution
- Correlation between two variables
- Karl Pearson's coefficient of correlation(r)
- Spearman's rank correlation
- Regression Analysis: Fitting of lines of regression by the least squares method
- coefficient of determination
- Problems and illustrative examples related to computer Science and IT
Karl Pearson's coefficient of correlation
2080 · 10 marks
Correlation and Regression Analysis
Show solved answerHide answer
Correlation and Regression Analysis
Given Data
$n = 8$
| Number of weeks (x) | 4 | 5 | 3 | 9 | 7 | 10 | 4 | 5 |
|---|---|---|---|---|---|---|---|---|
| Speed gain (y) | 85 | 120 | 48 | 192 | 164 | 234 | 74 | 110 |
Meaning of Correlation Types
i. Positive Correlation: Two variables move in the same direction. When one increases, the other also increases (and vice versa). Example: height and weight.
ii. Negative Correlation: Two variables move in opposite directions. When one increases, the other decreases. Example: price and demand.
iii. Perfect Correlation: A change in one variable produces an exactly proportional change in the other, so all points lie on a straight line. Perfect positive gives $r = +1$; perfect negative gives $r = -1$.
Calculation Table
| x | y | x² | y² | xy |
|---|---|---|---|---|
| 4 | 85 | 16 | 7225 | 340 |
| 5 | 120 | 25 | 14400 | 600 |
| 3 | 48 | 9 | 2304 | 144 |
| 9 | 192 | 81 | 36864 | 1728 |
| 7 | 164 | 49 | 26896 | 1148 |
| 10 | 234 | 100 | 54756 | 2340 |
| 4 | 74 | 16 | 5476 | 296 |
| 5 | 110 | 25 | 12100 | 550 |
| Σx=47 | Σy=1027 | Σx²=321 | Σy²=160021 | Σxy=7146 |
Verification of sums: $\Sigma x = 47$, $\Sigma y = 1027$, $\Sigma x^2 = 321$, $\Sigma xy = 7146$, and $\Sigma y^2 = 160021$. All confirmed.
Part (a): Correlation Coefficient
$$r = \frac{n\Sigma xy - \Sigma x \Sigma y}{\sqrt{[n\Sigma x^2 - (\Sigma x)^2][n\Sigma y^2 - (\Sigma y)^2]}}$$
Numerator: $$8(7146) - 47(1027) = 57168 - 48269 = 8899$$
First bracket: $$8(321) - 47^2 = 2568 - 2209 = 359$$
Second bracket: $$8(160021) - 1027^2 = 1280168 - 1054729 = 225439$$
$$r = \frac{8899}{\sqrt{359 \times 225439}} = \frac{8899}{\sqrt{80932601}} = \frac{8899}{8996.26}$$
$$\boxed{r \approx 0.989}$$
Interpretation: Since $r = 0.989$ is very close to $+1$, there is a very high positive correlation between weeks in the program and speed gain. As weeks increase, speed gain increases strongly.
Part (b): Regression Equation of Speed Gain (y) on Weeks (x)
$$\hat{y} = a + bx$$
$$b = \frac{n\Sigma xy - \Sigma x \Sigma y}{n\Sigma x^2 - (\Sigma x)^2} = \frac{8899}{359} = 24.79$$
$$\bar{x} = \frac{47}{8} = 5.875, \quad \bar{y} = \frac{1027}{8} = 128.375$$
$$a = \bar{y} - b\bar{x} = 128.375 - 24.79(5.875) = 128.375 - 145.64 = -17.26$$
$$\boxed{\hat{y} = -17.26 + 24.79x}$$
Part (c): Estimate for 6 Weeks and Slope Interpretation
$$\hat{y} = -17.26 + 24.79(6) = -17.26 + 148.74 = 131.48$$
$$\boxed{\hat{y} \approx 131.48 \text{ units of speed gain}}$$
Slope interpretation: $b = 24.79$ means that for each additional week in the program, the reading speed gain increases by about 24.79 units on average.
2079 · 10 marks
Question
What are the assumptions of Pearson's correlation? Bradford Electric Illuminating is studying the relationship between kilowatt-hours (thousands) used and the number of rooms in private single-family residences. A random sample of 5 houses yields the following.
$$\begin{array}{c|ccccc} \text{Number of rooms} & 11 & 10 & 14 & 7 & 9 \ \hline \text{Kilowatts-hours (thousands) used} & 9 & 8 & 11 & 5 & 9 \ \end{array}$$
i. Find the correlation coefficient between the number of rooms and kilowatts-hours used. Interpret the result.
ii. Determine the regression equation of kilowatts hours used on the number of rooms. Interpret the value of the regression coefficient.
iii. Estimate the kilowatts-hours used for an 8 rooms house.
[10]
2080.1 · 10 marks
Difference between Correlation and Regression Analysis
Raw materials are used in the production of synthesis and fiber are stored in a place which has no humidity control. Measurement of relative humidity in the storage place and the moisture content of a sample of raw materials (both in percentage) on 10 days yields the following results.
$$\begin{array}{c|cccccccccc} \text{Humidity % (X)} & 48 & 55 & 30 & 44 & 36 & 31 & 62 & 48 & 42 & 50 \ \text{Moisture content % (Y)} & 11 & 13 & 10 & 12 & 9 & 7 & 16 & 11 & 9 & 14 \ \end{array}$$
i. Compute correlation coefficient between humidity and moisture content and interpret the result.
ii. Find the regression equation of moisture content on humidity.
iii. Estimate the moisture content if humidity is 45%.
iv. Interpret the value of regression coefficient.
[10]
Show solved answerHide answer
Difference Between Correlation and Regression Analysis
| Basis | Correlation | Regression |
|---|---|---|
| Meaning | Measures degree and direction of linear relationship between two variables | Establishes functional relationship to predict one variable from another |
| Purpose | Find strength of association | Estimate/predict dependent variable |
| Variables | Both treated equally | One independent (X), one dependent (Y) |
| Result | A single value $r \in [-1, +1]$ | An equation (regression line) |
| Symmetry | $r(X,Y)=r(Y,X)$ | Regression of Y on X $\neq$ X on Y |
| Cause-Effect | Does not imply causation | Assumes a dependence relationship |
Given Data
$n = 10$
| X | 48 | 55 | 30 | 44 | 36 | 31 | 62 | 48 | 42 | 50 |
|---|---|---|---|---|---|---|---|---|---|---|
| Y | 11 | 13 | 10 | 12 | 9 | 7 | 16 | 11 | 9 | 14 |
Preliminary Calculations
| X | Y | X² | Y² | XY |
|---|---|---|---|---|
| 48 | 11 | 2304 | 121 | 528 |
| 55 | 13 | 3025 | 169 | 715 |
| 30 | 10 | 900 | 100 | 300 |
| 44 | 12 | 1936 | 144 | 528 |
| 36 | 9 | 1296 | 81 | 324 |
| 31 | 7 | 961 | 49 | 217 |
| 62 | 16 | 3844 | 256 | 992 |
| 48 | 11 | 2304 | 121 | 528 |
| 42 | 9 | 1764 | 81 | 378 |
| 50 | 14 | 2500 | 196 | 700 |
| 446 | 112 | 20834 | 1318 | 5210 |
$$\bar{X}=\frac{446}{10}=44.6,\qquad \bar{Y}=\frac{112}{10}=11.2$$
$$\Sigma X^2-n\bar X^2 = 20834-10(44.6)^2=20834-19891.6=942.4$$ $$\Sigma Y^2-n\bar Y^2 = 1318-10(11.2)^2=1318-1254.4=63.6$$ $$\Sigma XY-n\bar X\bar Y = 5210-10(44.6)(11.2)=5210-4995.2=214.8$$
Part (i): Correlation Coefficient
$$r=\frac{\Sigma XY-n\bar X\bar Y}{\sqrt{(\Sigma X^2-n\bar X^2)(\Sigma Y^2-n\bar Y^2)}}=\frac{214.8}{\sqrt{942.4\times63.6}}$$
$$r=\frac{214.8}{\sqrt{59916.64}}=\frac{214.8}{244.78}\approx \boxed{0.877}$$
Interpretation: $r=0.877$ shows a strong positive linear relationship. As humidity increases, moisture content also increases.
Part (ii): Regression Equation of Y on X
$$b_{YX}=\frac{\Sigma XY-n\bar X\bar Y}{\Sigma X^2-n\bar X^2}=\frac{214.8}{942.4}=0.2279\approx 0.228$$
$$a=\bar Y-b\bar X=11.2-0.228(44.6)=11.2-10.169=1.031$$
$$\boxed{\hat Y = 1.03 + 0.228X}$$
Part (iii): Estimate Y when X = 45
$$\hat Y = 1.03 + 0.228(45)=1.03+10.26=\boxed{11.29%}$$
When humidity is 45%, estimated moisture content ≈ 11.29%.
Part (iv): Interpretation of Regression Coefficient
$b=0.228$ means that for every 1 percentage point increase in relative humidity, the moisture content increases on average by about 0.228 percentage points. The positive sign confirms a direct relationship: higher storage humidity leads to higher moisture in the raw materials.
Regression Analysis
2078 · 10 marks
Write the properties of correlation coefficient. The time it takes to transmit a file always depends on the file size. Suppose you transmitted 30 files, with the average size of 126 Kbytes and the standard deviation of 35 Kbytes. The average transmitted time was 0.04 seconds with the standard deviation 0.01 seconds. The correlation coefficient between the time and size was 0.86. Based on these data, fit a linear regression model and predict the time it take to transmit a 400Kbyte file.[10]
2076 · 10 marks
Question
A study was done to study the effect of ambient temperature on the electric power consumed by a chemical plant. Following table gives the data which are collected from an experimental pilot plant.
| Temperature (°F) | 27 | 45 | 72 | 58 | 31 | 60 | 34 | 74 |
|---|---|---|---|---|---|---|---|---|
| Electric Power (BTU) | 250 | 285 | 320 | 295 | 265 | 298 | 267 | 321 |
a. Identify which one is response variable, and fit a simple regression line, assuming that the relationship between them is linear.
b. Interpret the regression coefficient with reference to your problem.
c. Obtain coefficient of determination, and interpret this.
d. Based on the fitted model in (a), predict the power consumption for an ambient temperature of $65°F$. [10+0]
2075 · 10 marks
Regression Analysis: Normal Stress and Shear Resistance
Spearman's rank correlation
2078 · 5 marks
Calculate Spearman's rank correlation coefficient for the following ranks given by three judges in a music contest. Indicate which pair of judges has the nearest approaches to music.
$$\begin{array}{c|cccccccccc} \text{1}^{\text{st}}\text{ Judge} & 2 & 1 & 4 & 6 & 5 & 8 & 9 & 10 & 7 & 3 \ \text{2}^{\text{nd}}\text{ Judge} & 4 & 3 & 2 & 5 & 1 & 6 & 8 & 9 & 10 & 7 \ \text{3}^{\text{rd}}\text{ Judge} & 5 & 8 & 4 & 7 & 10 & 2 & 1 & 6 & 9 & 3 \ \end{array}$$
[5]
2076 · 5 marks
Question
Following data represent the preference of 10 students studying B.Sc(CSIT) towards two brands of computer namely Lenovo and Acer. Apply appropriate statistical tool to measure whether the brand preference is correlated. Also interpret your result.
$$\begin{array}{|c|c|c|c|c|c|c|c|c|c|c|}\hline \text{Computer} & \text{Student Preference} & & & & & & & & & \ \hline \text{Lenovo} & 5 & 2 & 9 & 8 & 1 & 10 & 3 & 4 & 6 & 7 \ \text{Acer} & 10 & 5 & 1 & 3 & 8 & 6 & 2 & 7 & 9 & 4 \ \hline \end{array}$$
[5]
2075 · 5 marks
Spearman's Rank Correlation Coefficient
As part of study of the psychological correlates of success in athletes, the following measurements are obtained from members of Nepal national football team. Calculate Spearman's rank correlation coefficient.
$$ \begin{array}{c|cccccccc} \text{Anger} & 6 & 7 & 5 & 21 & 13 & 5 & 13 & 14 \ \text{Vigor} & 30 & 23 & 29 & 22 & 19 & 19 & 28 & 19 \end{array} $$
[5]
Make Unit 7 stick
Practice STA169 with flashcards & quizzes