document.write( "Question 1167202: Run a regression analysis on the following bivariate set of data with y as the response variable.
\n" ); document.write( "x y
\n" ); document.write( "48.7 22.9
\n" ); document.write( "47.8 19.7
\n" ); document.write( "45.8 37.1
\n" ); document.write( "48.8 25.3
\n" ); document.write( "43.6 43.8
\n" ); document.write( "45.7 37.4
\n" ); document.write( "50.1 17.8
\n" ); document.write( "45.5 31.5
\n" ); document.write( "46.1 36
\n" ); document.write( "44.5 41.7
\n" ); document.write( "44.8 30.8
\n" ); document.write( "43.1 40.3\r
\n" ); document.write( "\n" ); document.write( "Find the correlation coefficient and report it accurate to three decimal places.
\n" ); document.write( "r = -.899\r
\n" ); document.write( "
\n" ); document.write( "\n" ); document.write( "What proportion of the variation in y can be explained by the variation in the values of x? Report answer as a percentage accurate to one decimal place. (If the answer is 0.84471, then it would be 84.5%...you would enter 84.5 without the percent symbol.)
\n" ); document.write( "r² = 80.8%\r
\n" ); document.write( "\n" ); document.write( "Based on the data, calculate the regression line (each value to three decimal places)\r
\n" ); document.write( "\n" ); document.write( "y = -3.615 x + 199.047\r
\n" ); document.write( "
\n" ); document.write( "\n" ); document.write( "Predict what value (on average) for the response variable will be obtained from a value of 49.3 as the explanatory variable. Use a significance level of α = 0.05 to assess the strength of the linear correlation.\r
\n" ); document.write( "\n" ); document.write( "What is the predicted response value? (Report answer accurate to one decimal place.)
\n" ); document.write( "y = \r
\n" ); document.write( "\n" ); document.write( "
\n" ); document.write( "

Algebra.Com's Answer #852337 by CPhill(1987)\"\" \"About 
You can put this solution on YOUR website!
```python?code_reference&code_event_index=2
\n" ); document.write( "import numpy as np
\n" ); document.write( "from scipy.stats import linregress\r
\n" ); document.write( "\n" ); document.write( "# Data
\n" ); document.write( "x = np.array([48.7, 47.8, 45.8, 48.8, 43.6, 45.7, 50.1, 45.5, 46.1, 44.5, 44.8, 43.1])
\n" ); document.write( "y = np.array([22.9, 19.7, 37.1, 25.3, 43.8, 37.4, 17.8, 31.5, 36.0, 41.7, 30.8, 40.3])\r
\n" ); document.write( "\n" ); document.write( "# Run linear regression
\n" ); document.write( "slope, intercept, r_value, p_value, std_err = linregress(x, y)\r
\n" ); document.write( "\n" ); document.write( "# 1. Correlation coefficient (r)
\n" ); document.write( "r = r_value\r
\n" ); document.write( "\n" ); document.write( "# 2. Coefficient of determination (r^2)
\n" ); document.write( "r_squared = r_value**2
\n" ); document.write( "r_squared_percent = r_squared * 100\r
\n" ); document.write( "\n" ); document.write( "# 3. Regression line: y = intercept + slope * x
\n" ); document.write( "# The slope is 'b' and the intercept is 'a' in the standard form y = a + bx
\n" ); document.write( "# The user's form is y = b x + a, so:
\n" ); document.write( "b = slope
\n" ); document.write( "a = intercept\r
\n" ); document.write( "\n" ); document.write( "# 4. Predicted response value (y_hat) for x = 49.3
\n" ); document.write( "x_predict = 49.3
\n" ); document.write( "y_predicted = intercept + slope * x_predict\r
\n" ); document.write( "\n" ); document.write( "# Print results with required formatting
\n" ); document.write( "print(f\"Correlation coefficient (r): {r:.3f}\")
\n" ); document.write( "print(f\"Coefficient of determination (r^2, percent): {r_squared_percent:.1f}\")
\n" ); document.write( "print(f\"Regression slope (b): {b:.3f}\")
\n" ); document.write( "print(f\"Regression intercept (a): {a:.3f}\")
\n" ); document.write( "print(f\"Predicted y for x=49.3: {y_predicted:.1f}\")
\n" ); document.write( "print(f\"P-value for correlation significance (used for assessing strength): {p_value:.4f}\")
\n" ); document.write( "print(f\"Significance Level (alpha): 0.05\")\r
\n" ); document.write( "\n" ); document.write( "```\r
\n" ); document.write( "\n" ); document.write( "```text?code_stdout&code_event_index=2
\n" ); document.write( "Correlation coefficient (r): -0.899
\n" ); document.write( "Coefficient of determination (r^2, percent): 80.8
\n" ); document.write( "Regression slope (b): -3.615
\n" ); document.write( "Regression intercept (a): 199.047
\n" ); document.write( "Predicted y for x=49.3: 20.9
\n" ); document.write( "P-value for correlation significance (used for assessing strength): 0.0001
\n" ); document.write( "Significance Level (alpha): 0.05\r
\n" ); document.write( "\n" ); document.write( "```\r
\n" ); document.write( "\n" ); document.write( "That's an excellent idea to double-check the calculations\! Running the regression analysis confirms your intermediate results and provides the final prediction.\r
\n" ); document.write( "\n" ); document.write( "Here are the confirmed results based on the data:\r
\n" ); document.write( "\n" ); document.write( " * **Correlation coefficient ($r$):**
\n" ); document.write( " $$r = -0.899$$\r
\n" ); document.write( "\n" ); document.write( " * **Proportion of variation in $y$ explained by $x$ ($r^2$):**
\n" ); document.write( " $$r^2 = (-0.899)^2 \approx 0.8082$$
\n" ); document.write( " As a percentage, this is **$80.8\%$**.\r
\n" ); document.write( "\n" ); document.write( " * **Regression line:**
\n" ); document.write( " $$\hat{y} = 199.047 - 3.615x$$
\n" ); document.write( " $$\hat{y} = -3.615x + 199.047$$\r
\n" ); document.write( "\n" ); document.write( "-----\r
\n" ); document.write( "\n" ); document.write( "## Predicted Response Value and Correlation Strength\r
\n" ); document.write( "\n" ); document.write( "The final step is to predict the response value and assess the correlation strength.\r
\n" ); document.write( "\n" ); document.write( "### Predicted Response Value\r
\n" ); document.write( "\n" ); document.write( "To predict the response variable ($\hat{y}$) for an explanatory variable value of $x = 49.3$, we substitute $49.3$ into the regression equation:\r
\n" ); document.write( "\n" ); document.write( "$$\hat{y} = -3.615(49.3) + 199.047$$
\n" ); document.write( "$$\hat{y} \approx -178.29495 + 199.047$$
\n" ); document.write( "$$\hat{y} \approx 20.75205$$\r
\n" ); document.write( "\n" ); document.write( "Rounding to one decimal place:
\n" ); document.write( "$$\hat{y} = \mathbf{20.8}$$\r
\n" ); document.write( "\n" ); document.write( "### Assessing Correlation Strength ($\alpha=0.05$)\r
\n" ); document.write( "\n" ); document.write( "To assess the strength of the linear correlation, we compare the **p-value** from the regression analysis to the significance level ($\alpha$).\r
\n" ); document.write( "\n" ); document.write( " * **P-value** $\approx 0.0001$
\n" ); document.write( " * **Significance Level** ($\alpha$) $= 0.05$\r
\n" ); document.write( "\n" ); document.write( "Since the p-value ($0.0001$) is much smaller than $\alpha$ ($0.05$), we reject the null hypothesis (that there is no linear correlation). Therefore, the linear correlation between $x$ and $y$ is **statistically significant** and is confirmed to be **strong**.\r
\n" ); document.write( "\n" ); document.write( "What is the predicted response value? (Report answer accurate to one decimal place.)
\n" ); document.write( "y = **20.8**
\n" ); document.write( "
\n" );