AR 모형 추정하기
이전 연습에서 생성한 모의 시계열 중 하나에 대해 AR(1) 모수 $\small \phi$를 추정해 보겠습니다. 모의 시계열은 모수가 이미 알려져 있으므로, 실제 데이터에 적용하기 전에 추정 절차를 이해하기에 좋은 연습입니다.
진짜 \(\small \phi\) 값이 0.9인 simulated_data_1에 대해 $\small \phi$의 추정치를 출력하세요. 추가로, 시계열 모형을 적합할 때 생성되는 전체 출력도 함께 출력해 보며, statsmodels에서 제공하는 다른 검정과 요약 통계가 무엇인지 살펴보세요.
이 연습은 강의의 일부입니다
Python으로 배우는 시계열 분석
연습 안내
statsmodels.tsa.arima.model모듈에서ARIMA클래스를 가져오세요.- 모의 데이터
simulated_data_1과 모형의 (p,d,q) 차수(이번에는 AR(1)이므로)order=(1,0,0)를 사용해ARIMA클래스 인스턴스mod를 생성하세요. mod에.fit()메서드를 적용해 모형을 적합하고, 결과 객체를res에 저장하세요..summary()메서드를 사용해 전체 결과 요약을 출력하세요..params[1]속성(괄호 없음)을 사용해 $\small \phi$의 추정치만 출력하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Import the ARIMA module from statsmodels
from statsmodels.tsa.arima.model import ARIMA
# Fit an AR(1) model to the first simulated data
mod = ARIMA(___, order=___)
res = mod.___
# Print out summary information on the fit
print(res.___)
# Print out the estimate for phi
print("When the true phi=0.9, the estimate of phi is:")
print(res.___)