#Q2)

#Importing the data
data1 = pd.read_excel(
    "C:\Users\Rachita\Desktop\IAQS\Second Year 2021-2022\Semester 4\Python\Problem 2.xlsx"
)


#Fitting regression models
X1 = np.array(data1["X1"]).reshape(-1, 1)
X1 = sm.add_constant(X1)
X2 = np.array(data1["X2"]).reshape(-1, 1)
X2 = sm.add_constant(X2)
X3 = np.array(data1["X3"]).reshape(-1, 1)
X3 = sm.add_constant(X3)
X4 = np.array(data1["X4"]).reshape(-1, 1)
X4 = sm.add_constant(X4)


Y1 = np.array(data1["Y1"]).reshape(-1, 1)
Y2 = np.array(data1["Y2"]).reshape(-1, 1)
Y3 = np.array(data1["Y3"]).reshape(-1, 1)
Y4 = np.array(data1["Y4"]).reshape(-1, 1)

model_1 = sm.OLS(Y1, X1)
print(model_1.fit().summary())

model_2 = sm.OLS(Y2, X2)
print(model_2.fit().summary())

model_3 = sm.OLS(Y3, X3)
print(model_3.fit().summary())

model_4 = sm.OLS(Y4, X4)
print(model_4.fit().summary())

#The four models have a smiliar R-Squared and Coefficient values as seen from the summary
#They also have a similar line of best fit 

