def plot_ccpr(results, exog_idx, ax=None):
 (fig, ax) = utils.create_mpl_ax(ax)
 (exog_name, exog_idx) = utils.maybe_name_or_idx(exog_idx, results.model)
 results = maybe_unwrap_results(results)
 x1 = results.model.exog[:, exog_idx]
 x1beta = (x1 * results.params[exog_idx])
 ax.plot(x1, (x1beta + results.resid), 'o')
 from statsmodels.tools.tools import add_constant
 mod = OLS(x1beta, add_constant(x1)).fit()
 params = mod.params
 fig = abline_plot(*params, **dict(ax=ax))
 ax.set_title('Component and component plus residual plot')
 ax.set_ylabel(('Residual + %s*beta_%d' % (exog_name, exog_idx)))
 ax.set_xlabel(('%s' % exog_name))
 return fig

def plot_ccpr ( results , exog_idx , ax = None ) : ( fig , ax ) = utils . create_mpl_ax ( ax ) ( exog_name , exog_idx ) = utils . maybe_name_or_idx ( exog_idx , results . model ) results = maybe_unwrap_results ( results ) x1 = results . model . exog [ : , exog_idx ] x1beta = ( x1 * results . params [ exog_idx ] ) ax . plot ( x1 , ( x1beta + results . resid ) , 'o' ) from statsmodels . tools . tools import add_constant mod = OLS ( x1beta , add_constant ( x1 ) ) . fit ( ) params = mod . params fig = abline_plot ( * params , ** dict ( ax = ax ) ) ax . set_title ( 'Component and component plus residual plot' ) ax . set_ylabel ( ( 'Residual + %s*beta_%d' % ( exog_name , exog_idx ) ) ) ax . set_xlabel ( ( '%s' % exog_name ) ) return fig
plot ccpr against one regressor .