def test_plotacf(): # Just test that it runs. fig = plt.figure() ax = fig.add_subplot(111) ar = np.r_[1., -0.9] ma = np.r_[1., 0.9] armaprocess = tsp.ArmaProcess(ar, ma) acf = armaprocess.acf(20)[:20] plotacf(acf, ax=ax) plt.close(fig)
subplotcount = 1 nrows = 4 for arcoef in arcoefs[:-1]: for macoef in macoefs[:-1]: ar = np.r_[1., -arcoef] ma = np.r_[1., macoef] #from statsmodels.sandbox.tsa.fftarma import ArmaFft as FftArmaProcess #y = tsp.arma_generate_sample(ar,ma,nsample, sig, burnin) #armaprocess = FftArmaProcess(ar, ma, nsample) #TODO: make n optional #armaprocess.plot4() armaprocess = tsp.ArmaProcess(ar, ma) acf = armaprocess.acf(20)[:20] pacf = armaprocess.pacf(20)[:20] ax = fig.add_subplot(nrows, 2, subplotcount) plotacf(acf, ax=ax) ## ax.set_title('Autocorrelation \nar=%s, ma=%rs' % (ar, ma), ## size='xx-small') ax.text( 0.7, 0.6, 'ar =%s \nma=%s' % (ar, ma), transform=ax.transAxes, horizontalalignment='left', #'right', size='xx-small') ax.set_xlim(-1, 20) subplotcount += 1 ax = fig.add_subplot(nrows, 2, subplotcount) plotacf(pacf, ax=ax) ## ax.set_title('Partial Autocorrelation \nar=%s, ma=%rs' % (ar, ma), ## size='xx-small')
fig.suptitle('ARMA: Autocorrelation (left) and Partial Autocorrelation (right)') subplotcount = 1 nrows = 4 for arcoef in arcoefs[:-1]: for macoef in macoefs[:-1]: ar = np.r_[1., -arcoef] ma = np.r_[1., macoef] #y = tsp.arma_generate_sample(ar,ma,nsample, sig, burnin) #armaprocess = FftArmaProcess(ar, ma, nsample) #TODO: make n optional #armaprocess.plot4() armaprocess = tsp.ArmaProcess(ar, ma) acf = armaprocess.acf(20)[:20] pacf = armaprocess.pacf(20)[:20] ax = fig.add_subplot(nrows, 2, subplotcount) plotacf(acf, ax=ax) ## ax.set_title('Autocorrelation \nar=%s, ma=%rs' % (ar, ma), ## size='xx-small') ax.text(0.7, 0.6, 'ar =%s \nma=%s' % (ar, ma), transform=ax.transAxes, horizontalalignment='left', #'right', size='xx-small') ax.set_xlim(-1,20) subplotcount +=1 ax = fig.add_subplot(nrows, 2, subplotcount) plotacf(pacf, ax=ax) ## ax.set_title('Partial Autocorrelation \nar=%s, ma=%rs' % (ar, ma), ## size='xx-small') ax.text(0.7, 0.6, 'ar =%s \nma=%s' % (ar, ma), transform=ax.transAxes, horizontalalignment='left', #'right',
print(acf1[:10]) print(acovf1b[:10]) print(acf2[:10]) print(acf2m[:10]) x = arma_generate_sample([1.0, -0.8], [1.0], 500) print(acf(x)[:20]) import statsmodels.api as sm print(sm.regression.yule_walker(x, 10)) import matplotlib.pyplot as plt #ax = plt.axes() plt.plot(x) #plt.show() plt.figure() pltxcorr(plt,x,x) plt.figure() pltxcorr(plt,x,x, usevlines=False) plt.figure() #FIXME: plotacf was moved to graphics/tsaplots.py, and interface changed plotacf(plt, acf1[:20], np.arange(len(acf1[:20])), usevlines=True) plt.figure() ax = plt.subplot(211) plotacf(ax, acf1[:20], usevlines=True) ax = plt.subplot(212) plotacf(ax, acf1[:20], np.arange(len(acf1[:20])), usevlines=False) #plt.show()
acovf1b = acovf(arrvs[0], unbiased=False) acf2 = autocorr(arrvs[0]) acf2m = autocorr(arrvs[0] - arrvs[0].mean()) print(acf1[:10]) print(acovf1b[:10]) print(acf2[:10]) print(acf2m[:10]) x = arma_generate_sample([1.0, -0.8], [1.0], 500) print(acf(x)[:20]) print(sm.regression.yule_walker(x, 10)) #ax = plt.axes() plt.plot(x) #plt.show() plt.figure() pltxcorr(plt, x, x) plt.figure() pltxcorr(plt, x, x, usevlines=False) plt.figure() #FIXME: plotacf was moved to graphics/tsaplots.py, and interface changed plotacf(plt, acf1[:20], np.arange(len(acf1[:20])), usevlines=True) plt.figure() ax = plt.subplot(211) plotacf(ax, acf1[:20], usevlines=True) ax = plt.subplot(212) plotacf(ax, acf1[:20], np.arange(len(acf1[:20])), usevlines=False) #plt.show()