我有以下代码:
from statsmodels.graphics.tsaplots import plot_acf, plot_pacf
from pandas import ExcelWriter
import numpy as np
import pandas as pd
import seaborn as sns
import statsmodels.formula.api as smf
import statsmodels.tsa.api as smt
import statsmodels.api as sm
import scipy.stats as scs
from arch import arch_model
import sys
import matplotlib.pyplot as plt
import matplotlib as mpl
%matplotlib inline
df1 = df[['EURUSD Curncy']]
df1 = df1['EURUSD Curncy']
def tsplot(y, lags=None, figsize=(15, 12), style='bmh'):
if not isinstance(y, pd.Series):
y = pd.Series(y)
with plt.style.context(style):
fig = plt.figure(figsize=figsize)
#mpl.rcParams['font.family'] = 'Ubuntu Mono'
layout = (3, 2)
ts_ax = plt.subplot2grid(layout, (0, 0), colspan=2)
acf_ax = plt.subplot2grid(layout, (1, 0))
pacf_ax = plt.subplot2grid(layout, (1, 1))
qq_ax = plt.subplot2grid(layout, (2, 0))
pp_ax = plt.subplot2grid(layout, (2, 1))
y.plot(ax=ts_ax)
ts_ax.set_title('Time Series Analysis Plots')
smt.graphics.plot_acf(y, lags=lags, ax=acf_ax, alpha=0.5)#<-- this line here the issue
smt.graphics.plot_pacf(y, lags=lags, ax=pacf_ax, alpha=0.5)#<-- this line here the issue
sm.qqplot(y, line='s', ax=qq_ax)
qq_ax.set_title('QQ Plot')
scs.probplot(y, sparams=(y.mean(), y.std()), plot=pp_ax)
plt.tight_layout()
return
tsplot(df1.pct_change().dropna(), lags=30)
tsplot(df1.pct_change().dropna()**2, lags=30)
但是我要求的置信区间为 95%(alpha=0.5)并没有绘制出来。如果我将该行从函数中取出,它会起作用并显示间隔。
我被困住了,你能帮忙吗?谢谢