def test_whiteness(self, nlags=10, plot=True, linewidth=8): """ Test white noise assumption. Sample (Y) autocorrelations are compared with the standard :math:`2 / \sqrt(T)` bounds. Parameters ---------- plot : boolean, default True Plot autocorrelations with 2 / sqrt(T) bounds """ acorrs = self.sample_acorr(nlags) bound = 2 / np.sqrt(self.nobs) # TODO: this probably needs some UI work if (np.abs(acorrs) > bound).any(): print ('FAIL: Some autocorrelations exceed %.4f bound. ' 'See plot' % bound) else: print 'PASS: No autocorrelations exceed %.4f bound' % bound if plot: fig = plotting.plot_full_acorr(acorrs[1:], xlabel=np.arange(1, nlags+1), err_bound=bound, linewidth=linewidth) fig.suptitle(r"ACF plots with $2 / \sqrt{T}$ bounds " "for testing whiteness assumption")
def test_whiteness(self, nlags=10, plot=True, linewidth=8): """ Test white noise assumption. Sample (Y) autocorrelations are compared with the standard :math:`2 / \sqrt(T)` bounds. Parameters ---------- plot : boolean, default True Plot autocorrelations with 2 / sqrt(T) bounds """ acorrs = self.sample_acorr(nlags) bound = 2 / np.sqrt(self.nobs) # TODO: this probably needs some UI work if (np.abs(acorrs) > bound).any(): print( 'FAIL: Some autocorrelations exceed %.4f bound. ' 'See plot' % bound) else: print 'PASS: No autocorrelations exceed %.4f bound' % bound if plot: fig = plotting.plot_full_acorr(acorrs[1:], xlabel=np.arange(1, nlags + 1), err_bound=bound, linewidth=linewidth) fig.suptitle(r"ACF plots with $2 / \sqrt{T}$ bounds " "for testing whiteness assumption")
def plot_sample_acorr(self, nlags=10, linewidth=8): "Plot theoretical autocorrelation function" plotting.plot_full_acorr(self.sample_acorr(nlags=nlags), linewidth=linewidth)