'Plot the CUSUM of squares statistic and significance bounds.
Parameters
alpha : float, optional
The plotted significance bounds are alpha %.
legend_loc : string, optional
The location of the legend in the plot. Default is upper left.
fig : Matplotlib Figure instance, optional
If given, subplots are created in this figure instead of in a new
figure. Note that the grid will be created in the provided
figure using `fig.add_subplot()`.
figsize : tuple, optional
If a figure is created, this argument allows specifying a size.
The tuple is (width, height).
Notes
Evidence of parameter instability may be found if the CUSUM of squares
statistic moves out of the significance bounds.
Critical values used in creating the significance bounds are computed
using the approximate formula of [2]_.
References
.. [1] Brown, R. L., J. Durbin, and J. M. Evans. 1975.
"Techniques for Testing the Constancy of
Regression Relationships over Time."
Journal of the Royal Statistical Society.
Series B (Methodological) 37 (2): 149-92.
.. [2] Edgerton, David, and Curt Wells. 1994.
"Critical Values for the Cusumsq Statistic
in Medium and Large Sized Samples."
Oxford Bulletin of Economics and Statistics 56 (3): 355-65.'

def plot_cusum_squares(self, alpha=0.05, legend_loc='upper    left', fig=None, figsize=None):

    from statsmodels.graphics.utils import _import_mpl, create_mpl_fig
    plt = _import_mpl()
    fig = create_mpl_fig(fig, figsize)
    ax = fig.add_subplot(1, 1, 1)
    if (hasattr(self.data, 'dates') and (self.data.dates is not None)):
        dates = self.data.dates._mpl_repr()
    else:
        dates = np.arange(self.nobs)
    llb = self.loglikelihood_burn
    ax.plot(dates[llb:], self.cusum_squares, label='CUSUM    of    squares')
    ref_line = ((np.arange(llb, self.nobs) - llb) / (self.nobs - llb))
    ax.plot(dates[llb:], ref_line, 'k', alpha=0.3)
    (lower_line, upper_line) = self._cusum_squares_significance_bounds(alpha)
    ax.plot([dates[llb], dates[(-1)]], upper_line, 'k--', label=('%d%%    significance' % (alpha * 100)))
    ax.plot([dates[llb], dates[(-1)]], lower_line, 'k--')
    ax.legend(loc=legend_loc)
    return fig
