MA 모델 추정하기
이전 연습에서 생성한 모의 시계열 중 하나에 대해 MA(1) 모수 $\small \theta$를 추정해 보겠습니다. 모의 시계열은 참값을 알고 있으므로, 실제 데이터에 적용하기 전에 추정 절차를 이해하기에 좋습니다.
simulated_data_1의 참 $\small \theta\(가 -0.9일 때, \)\small \theta$의 추정치를 출력하세요. 추가로, 시계열 모델을 적합했을 때 생성되는 전체 출력도 함께 출력하여, statsmodels에서 제공하는 다른 검정과 요약 통계를 살펴보세요.
이 연습은 강의의 일부입니다
Python으로 배우는 시계열 분석
연습 안내
- 모듈
statsmodels.tsa.arima.model에서 클래스ARIMA를 임포트하세요. - 모형의 (p,d,q) 순서가 (이번 MA(1)에서는)
order=(0,0,1)이 되도록, 모의 데이터simulated_data_1을 사용해ARIMA클래스의 인스턴스mod를 생성하세요. - 메서드
.fit()으로 모델mod를 적합하고, 결과 객체를res에 저장하세요. .summary()메서드로 결과의 전체 요약을 출력하세요..params[1]속성으로 theta 모수의 추정치만 출력하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Import the ARIMA module from statsmodels
from statsmodels.tsa.arima.model import ARIMA
# Fit an MA(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 the constant and for theta
print("When the true theta=-0.9, the estimate of theta is:")
print(res.___)