AR 모형과 랜덤 워크 비교
약하게 평균회귀하는 시계열과 전혀 평균회귀하지 않는 시계열(예: 랜덤 워크)은 구분하기 어려울 때가 있습니다. 이번에는 이전 연습 문제의 약한 평균회귀 금리 시계열과 같은 관측치 수를 가진 모의 랜덤 워크의 ACF를 비교해 보세요.
두 시계열의 자기상관을 나란히 그려 보면 매우 비슷하게 보인다는 점을 확인하실 수 있을 거예요.
이 연습은 강의의 일부입니다
Python으로 배우는 시계열 분석
연습 안내
statsmodels모듈에서plot_acf함수를 가져오세요.- 두 개의 서브플롯을 위한 축(axes)을 만드세요.
- 위쪽 플롯에서 금리 시계열
interest_rate_data의 12시차 자기상관함수를 그리세요. - 아래쪽 플롯에서 시뮬레이션된 시계열
simulated_data의 12시차 자기상관함수를 그리세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Import the plot_acf module from statsmodels
from statsmodels.graphics.tsaplots import plot_acf
# Plot the interest rate series and the simulated random walk series side-by-side
fig, axes = plt.subplots(2,1)
# Plot the autocorrelation of the interest rate series in the top plot
fig = plot_acf(___, alpha=1, lags=12, ax=axes[0])
# Plot the autocorrelation of the simulated random walk series in the bottom plot
fig = plot_acf(___, alpha=1, lags=12, ax=axes[1])
# Label axes
axes[0].set_title("Interest Rate Data")
axes[1].set_title("Simulated Random Walk Data")
plt.show()