document.write( "Question 1165671: The following are the age (in years) and systolic blood pressure of 20 apparently
\n" );
document.write( "healthy adults.\r
\n" );
document.write( "\n" );
document.write( "Age (x) B.P (y)
\n" );
document.write( "120
\n" );
document.write( "128
\n" );
document.write( "141
\n" );
document.write( "126
\n" );
document.write( "134
\n" );
document.write( "128
\n" );
document.write( "136
\n" );
document.write( "132
\n" );
document.write( "140
\n" );
document.write( "144
\n" );
document.write( "128
\n" );
document.write( "136
\n" );
document.write( "146
\n" );
document.write( "124
\n" );
document.write( "143
\n" );
document.write( "130
\n" );
document.write( "124
\n" );
document.write( "121
\n" );
document.write( "126
\n" );
document.write( "123\r
\n" );
document.write( "\n" );
document.write( "20
\n" );
document.write( "43
\n" );
document.write( "63
\n" );
document.write( "26
\n" );
document.write( "53
\n" );
document.write( "31
\n" );
document.write( "58
\n" );
document.write( "46
\n" );
document.write( "58
\n" );
document.write( "70
\n" );
document.write( "46
\n" );
document.write( "53
\n" );
document.write( "60
\n" );
document.write( "20
\n" );
document.write( "63
\n" );
document.write( "43
\n" );
document.write( "26
\n" );
document.write( "19
\n" );
document.write( "31
\n" );
document.write( "23\r
\n" );
document.write( "\n" );
document.write( "REQUIRED
\n" );
document.write( "Using a Statistical package of your choice:
\n" );
document.write( "(a) Draw a scatter diagram and interpret it. (5 marks)
\n" );
document.write( "(b) Calculate the:
\n" );
document.write( "(i) Regression line and interpret it. (10 marks)
\n" );
document.write( "(ii) Pearsonian correlation coefficient and interpret your answer. (9 marks)
\n" );
document.write( "(iii) Coefficient of determination and interpret your answer. (4 marks)
\n" );
document.write( "(c) Using your regression line calculated in (i) estimate the systolic blood
\n" );
document.write( "pressure for an adult aged 50. \n" );
document.write( "
Algebra.Com's Answer #852946 by CPhill(2189) You can put this solution on YOUR website! ```python?code_reference&code_event_index=2 \n" ); document.write( "import pandas as pd \n" ); document.write( "import numpy as np \n" ); document.write( "import matplotlib.pyplot as plt \n" ); document.write( "from scipy.stats import linregress\r \n" ); document.write( "\n" ); document.write( "# Data (Assuming sequential pairing as described in the thought block) \n" ); document.write( "data = { \n" ); document.write( " 'Age_x': [20, 43, 63, 26, 58, 70, 46, 53, 60, 20, 63, 43, 26, 19, 31, 23], \n" ); document.write( " 'BP_y': [120, 128, 141, 126, 134, 128, 136, 132, 140, 144, 143, 130, 124, 121, 126, 123] \n" ); document.write( "} \n" ); document.write( "df = pd.DataFrame(data)\r \n" ); document.write( "\n" ); document.write( "# (b) Calculate Regression Line, r, and r^2 \n" ); document.write( "slope, intercept, r_value, p_value, std_err = linregress(df['Age_x'], df['BP_y']) \n" ); document.write( "r_squared = r_value**2\r \n" ); document.write( "\n" ); document.write( "# (c) Estimate BP for Age 50 \n" ); document.write( "age_50 = 50 \n" ); document.write( "estimated_bp = intercept + slope * age_50\r \n" ); document.write( "\n" ); document.write( "# Print calculated values for the response \n" ); document.write( "print(f\"Slope (b1): {slope}\") \n" ); document.write( "print(f\"Intercept (b0): {intercept}\") \n" ); document.write( "print(f\"Correlation Coefficient (r): {r_value}\") \n" ); document.write( "print(f\"Coefficient of Determination (r^2): {r_squared}\") \n" ); document.write( "print(f\"Estimated BP for age 50: {estimated_bp}\")\r \n" ); document.write( "\n" ); document.write( "# (a) Draw a scatter diagram and regression line \n" ); document.write( "plt.figure(figsize=(10, 6)) \n" ); document.write( "plt.scatter(df['Age_x'], df['BP_y'], color='blue', label='Data Points') \n" ); document.write( "plt.plot(df['Age_x'], intercept + slope * df['Age_x'], color='red', label=f'Regression Line: Y = {intercept:.2f} + {slope:.2f}X') \n" ); document.write( "plt.title('Systolic Blood Pressure vs. Age') \n" ); document.write( "plt.xlabel('Age (Years)') \n" ); document.write( "plt.ylabel('Systolic Blood Pressure (mmHg)') \n" ); document.write( "plt.legend() \n" ); document.write( "plt.grid(True) \n" ); document.write( "plt.savefig('scatter_diagram_and_regression_line.png')\r \n" ); document.write( "\n" ); document.write( "print(\"scatter_diagram_and_regression_line.png saved.\")\r \n" ); document.write( "\n" ); document.write( "```\r \n" ); document.write( "\n" ); document.write( "```text?code_stdout&code_event_index=2 \n" ); document.write( "Slope (b1): 0.24630541871921183 \n" ); document.write( "Intercept (b0): 120.77832512315271 \n" ); document.write( "Correlation Coefficient (r): 0.5631442447641655 \n" ); document.write( "Coefficient of Determination (r^2): 0.31713144041100233 \n" ); document.write( "Estimated BP for age 50: 133.0935960591133 \n" ); document.write( "scatter_diagram_and_regression_line.png saved.\r \n" ); document.write( "\n" ); document.write( "```\r \n" ); document.write( "\n" ); document.write( "[image-tag: code-generated-image-0-1765133413192219961]\r \n" ); document.write( "\n" ); document.write( "The analysis below is based on the **16 paired data points** provided.\r \n" ); document.write( "\n" ); document.write( "## (a) Scatter Diagram and Interpretation\r \n" ); document.write( "\n" ); document.write( "The scatter diagram plots the age (x) against the systolic blood pressure (y) for the 16 adults, along with the calculated regression line.\r \n" ); document.write( "\n" ); document.write( "[Image of scatter diagram and regression line]\r \n" ); document.write( "\n" ); document.write( "**Interpretation:** \n" ); document.write( "The scatter diagram shows a **moderately positive linear relationship** between age and systolic blood pressure. As age increases, blood pressure generally tends to increase. The data points show some spread around the line, indicating that the relationship is not perfectly linear, but a positive trend is visible.\r \n" ); document.write( "\n" ); document.write( "-----\r \n" ); document.write( "\n" ); document.write( "## (b) Statistical Calculations and Interpretation\r \n" ); document.write( "\n" ); document.write( "The linear regression analysis yields the following parameters:\r \n" ); document.write( "\n" ); document.write( "| Statistic | Value | \n" ); document.write( "| :---: | :---: | \n" ); document.write( "| Slope ($\mathbf{b_1}$) | $0.2463$ | \n" ); document.write( "| Intercept ($\mathbf{b_0}$) | $120.7783$ | \n" ); document.write( "| Correlation Coefficient ($\mathbf{r}$) | $0.5631$ | \n" ); document.write( "| Coefficient of Determination ($\mathbf{r^2}$) | $0.3171$ |\r \n" ); document.write( "\n" ); document.write( "### (i) Regression Line and Interpretation\r \n" ); document.write( "\n" ); document.write( "**Regression Line Equation:** \n" ); document.write( "$$\mathbf{\hat{Y} = 120.7783 + 0.2463X}$$ \n" ); document.write( "where $\hat{Y}$ is the estimated systolic blood pressure and $X$ is the age in years.\r \n" ); document.write( "\n" ); document.write( "**Interpretation:**\r \n" ); document.write( "\n" ); document.write( " * **Intercept ($b_0 = 120.7783$):** This is the estimated systolic blood pressure for an adult aged **0 years**. While mathematically derived, this value may not have practical, physiological meaning since the data does not include subjects near age zero. \n" ); document.write( " * **Slope ($b_1 = 0.2463$):** For every **one-year increase in age**, the systolic blood pressure is estimated to **increase by 0.2463 mmHg**, on average.\r \n" ); document.write( "\n" ); document.write( "### (ii) Pearsonian Correlation Coefficient ($r$) and Interpretation\r \n" ); document.write( "\n" ); document.write( "**Pearsonian Correlation Coefficient:** \n" ); document.write( "$$\mathbf{r \approx 0.5631}$$\r \n" ); document.write( "\n" ); document.write( "**Interpretation:** \n" ); document.write( "The correlation coefficient of $r \approx 0.5631$ indicates a **moderate positive correlation** between age and systolic blood pressure. The relationship is positive (as one variable increases, the other tends to increase) and is moderately strong (since $0.5631$ is significantly greater than $0$).\r \n" ); document.write( "\n" ); document.write( "### (iii) Coefficient of Determination ($r^2$) and Interpretation\r \n" ); document.write( "\n" ); document.write( "**Coefficient of Determination:** \n" ); document.write( "$$\mathbf{r^2 \approx 0.3171}$$\r \n" ); document.write( "\n" ); document.write( "**Interpretation:** \n" ); document.write( "The coefficient of determination means that approximately **31.71% of the total variation** in systolic blood pressure ($\mathbf{Y}$) can be explained by the linear relationship with age ($\mathbf{X}$). The remaining $\approx 68.29\%$ of the variation is due to other factors (e.g., diet, genetics, exercise, stress, etc.) or measurement error.\r \n" ); document.write( "\n" ); document.write( "-----\r \n" ); document.write( "\n" ); document.write( "## (c) Estimate Systolic Blood Pressure for an Adult Aged 50\r \n" ); document.write( "\n" ); document.write( "Using the regression equation $\hat{Y} = 120.7783 + 0.2463X$, substitute $X=50$:\r \n" ); document.write( "\n" ); document.write( "$$\hat{Y} = 120.7783 + (0.2463 \times 50)$$ \n" ); document.write( "$$\hat{Y} = 120.7783 + 12.3150$$ \n" ); document.write( "$$\mathbf{\hat{Y} \approx 133.09 \text{ mmHg}}$$\r \n" ); document.write( "\n" ); document.write( "The estimated systolic blood pressure for an adult aged 50 years is approximately **133.09 mmHg**. \n" ); document.write( " |