# Pastebin ziSfSGZD import numpy as np import pandas as pd import statsmodels.api as sm # Sample data data = { 'Year': [2010, 2011, 2012, 2013, 2014, 2015], 'New_Home_Sales': [321, 361, 388, 442, 501, 550], 'Durable_Goods_Orders': [125, 130, 135, 140, 145, 150], 'Unemployment_Claims': [550, 520, 490, 460, 430, 400], 'GDP': [14.87, 15.23, 15.6, 16.15, 16.91, 17.4] } df = pd.DataFrame(data) # Define the features and target variable X = df[['New_Home_Sales', 'Durable_Goods_Orders', 'Unemployment_Claims']] y = df['GDP'] # Add a constant term to the features X = sm.add_constant(X) # Create and fit the multiple regression model model = sm.OLS(y, X) results = model.fit() # Print the regression results print(results.summary()) # Forecast GDP for a new set of data new_data = { 'New_Home_Sales': [590, 630, 670], 'Durable_Goods_Orders': [155, 160, 165], 'Unemployment_Claims': [370, 340, 320] } new_df = pd.DataFrame(new_data) # Add a constant term to the new data new_X = sm.add_constant(new_df) # Make predictions using the fitted model new_predictions = results.predict(new_X) # Print the predicted GDP values print("Predicted GDP:") for i in range(len(new_predictions)): print(f"Input: {new_df.iloc[i]}, Predicted GDP: {new_predictions[i]}")