#Question 4.
import pandas as pd
import statsmodels.api as st
#Reading excel file
df=pd.read_excel("C:\\Users\\abhij\\Downloads\\AFB_END_DATA.xlsx",
sheet_name="Supermarket")
x=df[["Price","Advertising","Incentives","Salesforce"]]
#adding constant to model
x=st.add_constant(x)
print (x)
y=df[["Sales"]]
#Formulating model
results=st.OLS(y,x).fit()
#Printing results
print(results.summary())
#Question 4.b Sol
#b The regresion equation for the above table is Y = 1244.0741 - 133.4065*(Price) +
4.29*(Advertising) + 12.5063*(Incentives) + 17.3282*(Salesforce)
#c
#Price = 30 , advertisement = Rs 100 , Incentives = 100 , total salesforce = 10
p=30
ad=100
inc = 100
ts = 10
Predicted_Price = 1244.0741 - (133.4065*p) + (4.29*ad) + (12.5063*inc) +
(17.3282*ts)
print (Predicted_Price)
#d if p = p+10
p = 40
Predicted_Price = 1244.0741 - (133.4065*p) + (4.29*ad) + (12.5063*inc) +
(17.3282*ts)
print (Predicted_Price)
#e ad = ad+100
ad = 200
Predicted_Price = 1244.0741 - (133.4065*p) + (4.29*ad) + (12.5063*inc) +
(17.3282*ts)
print(Predicted_Price)
#f if ts = 20
ts = 20
Predicted_Price = 1244.0741 - (133.4065*p) + (4.29*ad) + (12.5063*inc) +
(17.3282*ts)
print (Predicted_Price)
#g Predicted_Price = 10000 , ts = 10 , p = 10 , inc= 200
Predictive_Price = 10000
ts = 10
p = 10
inc = 200
ad = ((Predictive_Price-1244.0741) + (133.4065*p) - (12.5063*inc) -
(17.3282*ts))/4.29
print(ad)