자기회귀(AR) 모형 추정하기
주어진 시계열 x에 대해 arima() 명령에서 order를 c(1, 0, 0)으로 설정하면 자기회귀(AR) 모형을 적합할 수 있습니다. 참고로 AR 모형은 ARIMA(1, 0, 0) 모형입니다.
이 연습에서는 모의 시계열 x와 AirPassengers 데이터를 대상으로 arima() 명령을 연습하며 AR 모형의 추가적인 특성을 살펴봅니다. 이 명령을 통해 모형의 추정 기울기(ar1), 평균(intercept), 혁신 분산(sigma^2)을 확인할 수 있습니다.
x와 AirPassengers 데이터는 모두 환경에 미리 로드되어 있습니다. 시계열 x는 오른쪽 그림에 표시되어 있습니다.
이 연습은 강의의 일부입니다
R로 배우는 시계열 분석
연습 안내
arima()를 사용해 시계열x에 AR 모형을 적합하세요. 이 명령의 출력을 자세히 살펴보세요.- 방금 실행한 명령에서 추정된 기울기(
ar1), 평균(intercept), 혁신 분산(sigma^2) 값은 무엇인가요? 해당 값을 R 작업 공간에 입력하세요. - 이제
AirPassengers에 AR 모형을 적합하고 결과를AR로 저장하세요.print()로 적합된 모형AR을 출력하세요. - 마지막으로 제공된 명령을 사용해
AirPassengers를 시각화하고, 적합값을 계산해 그림에 추가하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Fit the AR model to x
arima(___, order = ___)
# Copy and paste the slope (ar1) estimate
# Copy and paste the slope mean (intercept) estimate
# Copy and paste the innovation variance (sigma^2) estimate
# Fit the AR model to AirPassengers
AR <-
print(AR)
# Run the following commands to plot the series and fitted values
ts.plot(AirPassengers)
AR_fitted <- AirPassengers - residuals(AR)
points(AR_fitted, type = "l", col = 2, lty = 2)