Question: # Import necessary libraries import matplotlib.pyplot as plt import numpy as np # Enable inline plotting for Jupyter Notebook %matplotlib inline # Data points INC

# Import necessary libraries import matplotlib.pyplot as plt import numpy as np # Enable inline plotting for Jupyter Notebook %matplotlib inline # Data points INC = [5775, 9805, 13975, 19025, 12200, 7445, 9340, 20170, 22440, 4608, 24210, 19625, 13450, 5400, 6345, 5490, 20740, 22400, 18180, 15385] TIME = [16.20, 35.00, 27.00, 38.20, 25.00, 21.30, 40.20, 18.40, 32.00, 9.70, 28.00, 38.20, 20.00, 20.00, 20.00, 40.20, 26.00, 39.20, 32.00, 39.20] # Regression equation intercept = 19.626 slope = 0.0007 # Generate regression line points based on the data range x_vals = np.linspace(min(INC) - 1000, max(INC) + 1000, 100) # Extend range slightly for visibility y_vals = intercept + slope * x_vals # Plotting plt.figure(figsize=(10, 6)) # Scatterplot for data points plt.scatter(INC, TIME, color="blue", label="Data Points", zorder=2) # Regression line plt.plot(x_vals, y_vals, color="green", linestyle="--", label="Regression Line", zorder=3) # Customizing axes to include all data points plt.xlim(min(INC) - 1000, max(INC) + 1000) # Adjust limits dynamically plt.ylim(5, 45) # Y-axis range to cover all TIME values plt.xticks(np.arange(4000, 26001, 2000), fontsize=10) # X-axis ticks at intervals of 2000 plt.yticks(np.arange(5, 46, 5), fontsize=10) # Y-axis ticks at intervals of 5 # Titles and labels plt.title("Regression of TIME on INC", fontsize=14) plt.xlabel("INC (Income)", fontsize=12) plt.ylabel("TIME (Months to First Child)", fontsize=12) # Add grid and legend plt.grid(alpha=0.3, zorder=1) plt.legend(fontsize=10) # Display the plot inline plt.show()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!