Simple Linear Regression

An implementation in R Markdown

Angelica T. Masa, Ma. Angelika C. Regoso

07-29-2021

Problem

An article in the Journal of Sound and Vibration [“Measurement of Noise-Evoked Blood Pressure by Means of Averaging Method: Relation between Blood Pressure Rise and PSL” (1991, Vol. 151(3), pp. 383-394)] described a study investigating the relationship between noise exposure and hypertension. The following data are representative of those reported in the article.

Table 1.1. Blood Pressure Rise and Sound Pressure Level

Blood Pressure Rise (mm Hg), y Sound Pressure Level (dB), x
1 60
0 63
1 65
2 70
5 70
1 70
4 80
6 90
2 80
3 80
5 85
4 89
6 90
8 90
4 90
5 90
7 94
9 100
7 100
6 100

Questions

A. Draw a scatter diagram of y (blood pressure rise in millimeters of mercury) versus x (sound pressure level in decibels). Does a simple linear regression model seem reasonable in this situation?

B. Fit the simple linear regression model using least squares. Find an estimate of σ2.

C. Find the predicted mean rise in blood pressure level associated with a sound pressure level of 85 decibels.


Answer to Part A:

Task: Draw a scatter diagram of y (blood pressure rise in millimeters of mercury) versus x (sound pressure level in decibels). Does a simple linear regression model seem reasonable in this situation?

data <- data.frame(
  y = c(1, 0, 1, 2, 5, 1, 4, 6, 2, 3, 5, 4, 6, 8, 4, 5, 7, 9, 7, 6),
  x = c(60, 63, 65, 70, 70, 70, 80, 90, 80, 80, 85, 89, 90, 90, 90, 90, 94, 100, 100, 100))

scatter.smooth(x=data$x, y=data$y, main="Blood Pressure Rise vs. Sound Pressure Level", xlab = "Sound Pressure Level (dB)", ylab = "Blood Pressure Rise (mm Hg)" )

Figure 1.1. Scatter diagram of y (blood pressure rise in millimeters of mercury) versus x (sound pressure level in decibels).

Figure 1.1. Scatter diagram of y (blood pressure rise in millimeters of mercury) versus x (sound pressure level in decibels).

Yes, a simple linear regression model seems reasonable in this situation. An increase in sound pressure level (in dB) causes a rise in the blood pressure level (in mm Hg).

Answer to Part B:

Task: Fit the simple linear regression model using least squares. Find an estimate of σ2.

We will fit a simple linear regression model:

\(\hat{y}\) = \(\hat{\beta}_0\) + \(\hat{\beta}_1\)x

where \(\hat{y}\) = blood pressure rise in millimeters of mercury and

x = sound pressure level in decibels.

Using Least Squares Method:

First, calculate Sxy, Sxx, and Syy.

x=data$x; y=data$y
Sxy = sum((x - mean(x)) * (y - mean(y)))
Sxx = sum((x - mean(x)) ^ 2)
Syy = sum((y - mean(y)) ^ 2)
c(Sxy, Sxx, Syy)
## [1]  533.2 3059.2  124.2

Sxy = 533.2

Sxx = 3059.2

Syy = 124.2

Then, calculate \(\hat{\beta}_0\) and \(\hat{\beta}_1\).

beta_1_hat = Sxy / Sxx
beta_0_hat = mean(y) - beta_1_hat * mean(x)
c(beta_0_hat, beta_1_hat)
## [1] -10.1315377   0.1742939

\(\hat{\beta}_0\) = -10.1315377

\(\hat{\beta}_1\) = 0.1742939

The least squares estimates of the intercept and slope are

\(\hat{\beta}_0\) = -10.1315377 and \(\hat{\beta}_1\) = 0.1742939.

Thus, the fitted simple linear regression model is

\(\hat{y}\) = -10.1315377 + 0.1742939x.

Practical Interpretation: The fitted simple linear regression model can be used in predicting the blood pressure rise in millimeters of mercury (y) for any given value of sound pressure level in decibels (x).

Figure 1.2. Scatter plot of y (blood pressure rise in millimeters of mercury) versus x (sound pressure level in decibels) and simple linear regression model \(\hat{y}\) = -10.1315377 + 0.1742939x.

Variance Estimation:

y_hat = beta_0_hat + beta_1_hat * x
e     = y - y_hat
n     = length(e)
σ_2_hat  = sum(e^2) / (n - 2)
σ_2_hat
## [1] 1.737026

The estimated σ2, \(\hat{\sigma}^2\) = 1.737026.

Check Using the lm Function:

linear.regression <- lm(y ~ x, data=data)
summary(linear.regression)
## 
## Call:
## lm(formula = y ~ x, data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.8120 -0.9040 -0.1333  0.5023  2.9310 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -10.13154    1.99490  -5.079 7.83e-05 ***
## x             0.17429    0.02383   7.314 8.57e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.318 on 18 degrees of freedom
## Multiple R-squared:  0.7483, Adjusted R-squared:  0.7343 
## F-statistic:  53.5 on 1 and 18 DF,  p-value: 8.567e-07

Indeed, the simple linear regression model is \(\hat{y}\) = -10.13154 + 0.17429x (rounded off to 5 dec. places), while the estimated σ2 can be calculated by squaring the value of the residual standard error/residual standard deviation, which is 1.3182 = 1.737 (rounded off to 3 dec. places).

Answer to Part C:

Task: Find the predicted mean rise in blood pressure level associated with a sound pressure level of 85 decibels.

To predict the mean rise in blood pressure level associated with a sound pressure level of 85 decibels, use the fitted simple linear regression model:

\(\hat{y}\) = -10.1315377 + 0.1742939x.

y_hat <- beta_0_hat + beta_1_hat * 85
y_hat
## [1] 4.683447

Thus, the estimated mean rise in blood pressure level associated with a sound pressure level of 85 decibels is 4.683447 mm Hg.