document.write( "Question 1164822: Find the equation of the least squares regression line (line of best fit). Note: Use the number of phones sold in the month of February as the independent variable, x, and the commission on those sales as the dependent variable, y. (No work required.)\r
\n" ); document.write( "
\n" ); document.write( "\n" ); document.write( "b. State the value of the correlation coefficient r and comment on the goodness of fit.\r
\n" ); document.write( "
\n" ); document.write( "
\n" ); document.write( "
\n" ); document.write( "\n" ); document.write( "Plans sold(x) Commission(y)
\n" ); document.write( "14. 243
\n" ); document.write( "16. 312
\n" ); document.write( "17. 279
\n" ); document.write( "18. 308
\n" ); document.write( "11 199
\n" ); document.write( "15. 219
\n" ); document.write( "23. 504
\n" ); document.write( "24. 550
\n" ); document.write( "14. 260
\n" ); document.write( "17. 255
\n" ); document.write( "
\n" ); document.write( "

Algebra.Com's Answer #853513 by CPhill(2189)\"\" \"About 
You can put this solution on YOUR website!
```python
\n" ); document.write( "import numpy as np
\n" ); document.write( "from scipy import stats
\n" ); document.write( "import matplotlib.pyplot as plt\r
\n" ); document.write( "\n" ); document.write( "x = np.array([14, 16, 17, 18, 11, 15, 23, 24, 14, 17])
\n" ); document.write( "y = np.array([243, 312, 279, 308, 199, 219, 504, 550, 260, 255])\r
\n" ); document.write( "\n" ); document.write( "slope, intercept, r_value, p_value, std_err = stats.linregress(x, y)\r
\n" ); document.write( "\n" ); document.write( "print(f\"{slope=}\")
\n" ); document.write( "print(f\"{intercept=}\")
\n" ); document.write( "print(f\"{r_value=}\")\r
\n" ); document.write( "\n" ); document.write( "# For plotting
\n" ); document.write( "plt.scatter(x, y, color='blue', label='Data Points')
\n" ); document.write( "plt.plot(x, slope * x + intercept, color='red', label='Regression Line')
\n" ); document.write( "plt.xlabel('Plans Sold (x)')
\n" ); document.write( "plt.ylabel('Commission (y)')
\n" ); document.write( "plt.title('Least Squares Regression Line')
\n" ); document.write( "plt.legend()
\n" ); document.write( "plt.grid(True)
\n" ); document.write( "plt.savefig('regression_plot.png')\r
\n" ); document.write( "
\n" ); document.write( "
\n" ); document.write( "\n" ); document.write( "```\r
\n" ); document.write( "\n" ); document.write( "```text
\n" ); document.write( "slope=27.894409937888202
\n" ); document.write( "intercept=-158.51552795031063
\n" ); document.write( "r_value=0.9431913989966259\r
\n" ); document.write( "
\n" ); document.write( "\n" ); document.write( "```\r
\n" ); document.write( "\n" ); document.write( "To find the least squares regression line and the correlation coefficient for the given data, we perform a linear regression analysis.\r
\n" ); document.write( "\n" ); document.write( "### a. Equation of the Least Squares Regression Line\r
\n" ); document.write( "\n" ); document.write( "Using the provided data, we calculate the slope () and the -intercept () for the equation .\r
\n" ); document.write( "\n" ); document.write( "* **Slope ():**
\n" ); document.write( "* **-intercept ():** \r
\n" ); document.write( "\n" ); document.write( "**The equation of the regression line is:**\r
\n" ); document.write( "
\n" ); document.write( "\n" ); document.write( "---\r
\n" ); document.write( "\n" ); document.write( "### b. Correlation Coefficient and Goodness of Fit\r
\n" ); document.write( "\n" ); document.write( "The correlation coefficient () measures the strength and direction of the linear relationship between the two variables.\r
\n" ); document.write( "\n" ); document.write( "* **Correlation Coefficient ():** \r
\n" ); document.write( "\n" ); document.write( "**Comment on Goodness of Fit:**
\n" ); document.write( "A correlation coefficient of **0.9432** indicates a **very strong positive linear relationship** between the number of plans sold and the commission earned. Since is close to 1, the regression line provides an excellent fit for the data, meaning that as the number of plans sold increases, the commission tends to increase in a highly predictable manner.\r
\n" ); document.write( "\n" ); document.write( "Would you like me to use this equation to predict the commission for a specific number of sales, such as 20 plans?
\n" ); document.write( "
\n" );