1

I have some OLS results that look like this:

                            OLS Regression Results                            
==============================================================================
Dep. Variable:     dependent_variable   R-squared:                       0.364
Model:                            OLS   Adj. R-squared:                  0.328
Method:                 Least Squares   F-statistic:                     10.09
Date:                Fri, 09 Mar 2018   Prob (F-statistic):           4.74e-20
Time:                        12:11:10   Log-Likelihood:                 210.15
No. Observations:                 299   AIC:                            -386.3
Df Residuals:                     282   BIC:                            -323.4
Df Model:                          16                                         
Covariance Type:            nonrobust                                         
==============================================================================
                 coef    std err          t      P>|t|      [0.025      0.975]
------------------------------------------------------------------------------
const         -1.4285      0.543     -2.629      0.009      -2.498      -0.359
SIM            0.0481      0.021      2.290      0.023       0.007       0.090
OIL            0.0902      0.080      1.124      0.262      -0.068       0.248
DEF           -0.0890      0.098     -0.907      0.365      -0.282       0.104
PE            -2.8715      0.638     -4.500      0.000      -4.128      -1.615
VRP           -0.6240      0.079     -7.866      0.000      -0.780      -0.468
CAPE          -2.5268      0.502     -5.035      0.000      -3.515      -1.539
BM             1.0856      0.291      3.730      0.000       0.513       1.659
CAY           -0.1232      0.036     -3.411      0.001      -0.194      -0.052
BDI            0.0533      0.070      0.766      0.444      -0.084       0.190
DP             1.5659      0.316      4.957      0.000       0.944       2.188
MA            -0.0518      0.077     -0.675      0.500      -0.203       0.099
NOS           -0.0847      0.048     -1.778      0.076      -0.179       0.009
PCAval         5.4010      1.117      4.834      0.000       3.202       7.600
CPI           -0.0837      0.075     -1.118      0.264      -0.231       0.064
BY            -0.1682      0.061     -2.779      0.006      -0.287      -0.049
TERM           0.0871      0.045      1.951      0.052      -0.001       0.175
==============================================================================
Omnibus:                        4.654   Durbin-Watson:                   1.904
Prob(Omnibus):                  0.098   Jarque-Bera (JB):                4.401
Skew:                           0.289   Prob(JB):                        0.111
Kurtosis:                       3.134   Cond. No.                         458.
==============================================================================

I want to generate a nice plot for this regression, however I'm not sure if there are any libraries designed for plotting multi-var regression. Nothing has worked so far, I have tried the answers listed here, to no avail.

Correlation DF looks like:

             SIM       OIL       DEF        PE       VRP     ERP4M      CAPE  \
SIM     1.000000 -0.050460  0.083599 -0.034125 -0.150744  0.064383  0.020047   
OIL    -0.050460  1.000000 -0.422509  0.037500 -0.043082  0.526773  0.248337   
DEF     0.083599 -0.422509  1.000000  0.621826  0.200023 -0.574159 -0.787776   
PE     -0.034125  0.037500  0.621826  1.000000  0.151396 -0.004591 -0.624840   
VRP    -0.150744 -0.043082  0.200023  0.151396  1.000000 -0.146723 -0.374840   
ERP4M   0.064383  0.526773 -0.574159 -0.004591 -0.146723  1.000000  0.272633   
CAPE    0.020047  0.248337 -0.787776 -0.624840 -0.374840  0.272633  1.000000   
BM     -0.013919 -0.278438  0.667338  0.425422  0.470390 -0.244372 -0.940337   
CAY    -0.012688 -0.042881  0.423774  0.155665  0.189580 -0.387483 -0.422951   
BDI    -0.059310  0.184701  0.014964  0.175442 -0.096856  0.009685 -0.051522   
DP      0.031967 -0.359831  0.910237  0.749141  0.250744 -0.445332 -0.867026   
MA     -0.011023  0.160401 -0.816400 -0.751237 -0.051251  0.398050  0.598858   
NOS     0.057399 -0.292519  0.501947  0.233667 -0.026792 -0.406684 -0.297782   
PCAval -0.046081  0.433105 -0.294880  0.384547 -0.278818  0.422584  0.463201   
SPX     0.037689  0.366747 -0.245153  0.110772 -0.489112  0.551562  0.103475   
CPI    -0.002426  0.302854 -0.401922 -0.613360 -0.106276 -0.149682  0.539511   
BY      0.028855  0.320562 -0.383879  0.002436 -0.086611  0.419317  0.292955   
TERM    0.025035 -0.025416  0.255060  0.316007  0.346241  0.082039 -0.623297   
ERP1M   0.037997  0.361399 -0.235481  0.117769 -0.477621  0.553413  0.079395 

I want to print every variable's correlation with ERP4M.

 corr = df.corr(method='pearson').loc[['ERP4M']]
 smg.plot_corr(corr_matrix, xnames=list(corr))
 plt.show()
Évariste Galois
  • 1,043
  • 2
  • 13
  • 27
  • There are tons of *"Nice Plots"* that can be created to visualize a regression. Residual plots, scatter plots, normal probability plots... which one are you looking for? – DJK Mar 09 '18 at 17:20
  • Ah, forgot to mention. Scatter plots followed by residual ideally, however if normal probability is possible I would like to know how to do it. – Évariste Galois Mar 09 '18 at 17:52
  • Check [these](http://www.statsmodels.org/dev/graphics.html) out – DJK Mar 09 '18 at 17:56
  • @DJK, I saw these, but I'm not sure how to have all of my independent variables be plotted on the axis axis vs my dependent variable. – Évariste Galois Mar 09 '18 at 18:55
  • In terms of a scatter plot, you cannot. Once you move out of 3 dimensions (i.e. 2 x's) you cannot plot these because you are in high dimensional space. You can plot each X vs. Y in 2d space – DJK Mar 09 '18 at 19:00
  • Ok, that makes sense. Regarding having multiple x values vs one y value for a correlation dataframe plot, I was having issues with that as well. Is that not possible either? – Évariste Galois Mar 09 '18 at 19:02
  • Please add some sample data and a snipped of the code that is an issue – DJK Mar 09 '18 at 19:05
  • Well, my code works, but I was wondering if there was a more intuitive/nice plot for a correlation matrix. The one outputted by my code is a little hard to follow. – Évariste Galois Mar 09 '18 at 19:29
  • This question is quite confusing because one the one hand you want to create scatter plots and/or visualize the correlation matrix, but you've also presented a multiple regression model. Any plots you create using the raw data will NOT be representative of the regression you're trying to model (i.e. a plot between raw `x` and `y` will not show you the same thing as the regression between `x` and `y`). Multiple regression coefficients are conditional upon the other inputs and are partial relationships controlling for the other IVs. So what are you intending to show wrt the regression model? – Simon Mar 09 '18 at 23:33

0 Answers0