SHARE
TWEET

Assignment2EM

a guest Feb 19th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import pandas as pd #to read and manipulate data
  2. import matplotlib.pyplot as plt #to draw graphs
  3. import numpy as np #to do scientific computing if any
  4. from statsmodels.formula.api import ols #for linear regression
  5. from statsmodels.api import qqplot
  6. from statsmodels.stats.diagnostic import het_breuschpagan #for Breusch-Pagan test test
  7. import seaborn as sns #for heatmap
  8. from scipy import stats
  9. from statsmodels.stats.diagnostic import linear_rainbow #linearity test
  10. from scipy.stats import shapiro #for checking normality
  11. from statsmodels.stats.outliers_influence import variance_inflation_factor #for checking Multicolinearity
  12.  
  13.  
  14. data=pd.read_excel("CLV.xlsx")
  15.  
  16.  
  17. model=ols(formula="Final_Grade~failures+romantic", data=data)
  18.  
  19. results=model.fit()
  20.  
  21. results.summary()
  22.  
  23. residuals=results.resid
  24.  
  25. het_breuschpagan(residuals,model.exog)
  26.  
  27. linear_rainbow(results)
  28.  
  29. stat,p = shapiro(residuals)
  30. print(stat,p)
  31.  
  32. my_list=['romantic','failures']
  33.  
  34. vif = [variance_inflation_factor(db[my_list].values, i) for i in range(0,5)]
  35. print(vif)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top