'Diagnostic plots for standardized residuals of one endogenous variable
Parameters
variable : integer, optional
Index of the endogenous variable for which the diagnostic plots
should be created. Default is 0.
lags : integer, optional
Number of lags to include in the correlogram. Default is 10.
fig : Matplotlib Figure instance, optional
If given, subplots are created in this figure instead of in a new
figure. Note that the 2x2 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
Produces a 2x2 plot grid with the following plots (ordered clockwise
from top left):
1. Standardized residuals over time
2. Histogram plus estimated density of standardized residulas, along
with a Normal(0,1) density plotted for reference.
3. Normal Q-Q plot, with Normal reference line.
4. Correlogram
See Also
statsmodels.graphics.gofplots.qqplot
statsmodels.graphics.tsaplots.plot_acf'

def plot_diagnostics(self, variable=0, lags=10, fig=None, figsize=None):

    from statsmodels.graphics.utils import _import_mpl, create_mpl_fig
    _import_mpl()
    fig = create_mpl_fig(fig, figsize)
    d = self.loglikelihood_burn
    resid = self.filter_results.standardized_forecasts_error[variable, d:]
    ax = fig.add_subplot(221)
    if (hasattr(self.data, 'dates') and (self.data.dates is not None)):
        x = self.data.dates[self.loglikelihood_burn:]._mpl_repr()
    else:
        x = np.arange(len(resid))
    ax.plot(x, resid)
    ax.hlines(0, x[0], x[(-1)], alpha=0.5)
    ax.set_xlim(x[0], x[(-1)])
    ax.set_title('Standardized    residual')
    resid_nonmissing = resid[(~ np.isnan(resid))]
    ax = fig.add_subplot(222)
    ax.hist(resid_nonmissing, normed=True, label='Hist')
    from scipy.stats import gaussian_kde, norm
    kde = gaussian_kde(resid_nonmissing)
    xlim = (((-1.96) * 2), (1.96 * 2))
    x = np.linspace(xlim[0], xlim[1])
    ax.plot(x, kde(x), label='KDE')
    ax.plot(x, norm.pdf(x), label='N(0,1)')
    ax.set_xlim(xlim)
    ax.legend()
    ax.set_title('Histogram    plus    estimated    density')
    ax = fig.add_subplot(223)
    from statsmodels.graphics.gofplots import qqplot
    qqplot(resid_nonmissing, line='s', ax=ax)
    ax.set_title('Normal    Q-Q')
    ax = fig.add_subplot(224)
    from statsmodels.graphics.tsaplots import plot_acf
    plot_acf(resid, ax=ax, lags=lags)
    ax.set_title('Correlogram')
    ax.set_ylim((-1), 1)
    return fig
