│ │ │ Diagnostics and specification tests
│ │ │ statsmodels allows you to conduct a range of useful regression diagnostics
│ │ │ and specification tests. For instance,
│ │ │ apply the Rainbow test for linearity (the null hypothesis is that the
│ │ │ relationship is properly modelled as linear):
│ │ │ In [18]: sm.stats.linear_rainbow(res)
│ │ │ -Out[18]: (np.float64(0.8472339976156905), np.float64(0.6997965543621659))
│ │ │ +Out[18]: (np.float64(0.847233997615691), np.float64(0.6997965543621643))
│ │ │
│ │ │
│ │ │ Admittedly, the output produced above is not very verbose, but we know from
│ │ │ reading the docstring
│ │ │ (also, print(sm.stats.linear_rainbow.__doc__)) that the
│ │ │ first number is an F-statistic and that the second is the p-value.
│ │ │ statsmodels also provides graphics functions. For example, we can draw a
│ │ │ ├── html2text {}
│ │ │ │ @@ -187,23 +187,23 @@
│ │ │ │ Region[T.S] -4.548257
│ │ │ │ Region[T.W] -10.091276
│ │ │ │ Literacy -0.185819
│ │ │ │ Wealth 0.451475
│ │ │ │ dtype: float64
│ │ │ │
│ │ │ │ In [17]: res.rsquared
│ │ │ │ -Out[17]: np.float64(0.3379508691928822)
│ │ │ │ +Out[17]: np.float64(0.337950869192882)
│ │ │ │ Type dir(res) for a full list of attributes.
│ │ │ │ For more information and examples, see the _R_e_g_r_e_s_s_i_o_n_ _d_o_c_ _p_a_g_e
│ │ │ │ ********** DDiiaaggnnoossttiiccss aanndd ssppeecciiffiiccaattiioonn tteessttss_## **********
│ │ │ │ statsmodels allows you to conduct a range of useful _r_e_g_r_e_s_s_i_o_n_ _d_i_a_g_n_o_s_t_i_c_s_ _a_n_d
│ │ │ │ _s_p_e_c_i_f_i_c_a_t_i_o_n_ _t_e_s_t_s. For instance, apply the Rainbow test for linearity (the
│ │ │ │ null hypothesis is that the relationship is properly modelled as linear):
│ │ │ │ In [18]: sm.stats.linear_rainbow(res)
│ │ │ │ -Out[18]: (np.float64(0.8472339976156905), np.float64(0.6997965543621659))
│ │ │ │ +Out[18]: (np.float64(0.847233997615691), np.float64(0.6997965543621643))
│ │ │ │ Admittedly, the output produced above is not very verbose, but we know from
│ │ │ │ reading the _d_o_c_s_t_r_i_n_g (also, print(sm.stats.linear_rainbow.__doc__)) that the
│ │ │ │ first number is an F-statistic and that the second is the p-value.
│ │ │ │ statsmodels also provides graphics functions. For example, we can draw a plot
│ │ │ │ of partial regression for a set of regressors by:
│ │ │ │ In [19]: sm.graphics.plot_partregress('Lottery', 'Wealth', ['Region',
│ │ │ │ 'Literacy'],