You are on page 1of 2

import pandas as pd

MLR_df = pd.read_csv('MLR.csv')
MLR_df.info()
MLR_df.iloc[0:15, 0:4]

X_features = ['CTRP','Promotion']
MLR_X_df = MLR_df[X_features]
MLR_X_df.iloc[0:15, 0:4]

import numpy as np
import statsmodels.api as sm
X = sm.add_constant(MLR_X_df)
X.iloc[0:15, 0:4]
Y=MLR_df['Revenue']
MLR_lm = sm.OLS( Y, X ).fit()
print( MLR_lm.params )
MLR_lm.summary2()

==============================================
Multi-Collinearity steps

import pandas as pd
MLR_df = pd.read_csv('MLR_MC.csv')
MLR_df.info()
MLR_df.iloc[0:15, 0:4]

X_features = ['CTRP','CTRP2','Promotion']
MLR_X_df = MLR_df[X_features]
MLR_X_df.iloc[0:15, 0:4]

import numpy as np
import statsmodels.api as sm
X = sm.add_constant(MLR_X_df)
X.iloc[0:15, 0:4]
Y=MLR_df['Revenue']
MLR_lm = sm.OLS( Y, X ).fit()
print( MLR_lm.params )
MLR_lm.summary2()

==============================================
Variance Inflation Factor (VIF) calculation steps

import pandas as pd
MLR_df = pd.read_csv('MLR_MC.csv')
MLR_df.info()
MLR_df.iloc[0:15, 0:4]

X_features = ['CTRP2']
MLR_X_df = MLR_df[X_features]
MLR_X_df.iloc[0:15, 0:4]
import numpy as np
import statsmodels.api as sm
X = sm.add_constant(MLR_X_df)
X.iloc[0:15, 0:4]
Y=MLR_df['CTRP']
MLR_lm = sm.OLS( Y, X ).fit()
print( MLR_lm.params )
MLR_lm.summary2()

You might also like