2016-06-24 2 views
1

forecast::auto.arima을 사용하여 시계열 예측을 실행 중이고 적합 시간 시리즈 개체에서 p, d, q (및 해당되는 경우 계절적으로) 할당 된 값을 추출하는 방법이 있는지 확인하려고했습니다. 예 :R에 맞는 ARIMA 모델로부터 p, d, q 값을 추출합니다.

fit <- auto.arima(mydata) 

auto.arima()ARIMA(1,1,0)(0,1,1)[12] 모델을 골랐다. 값이 p 인 경우 d, q (및 P, D, Q)의 값을 추출 할 수 있습니까? 결국 나는 다음과 같이 여섯 개 변수가 자동으로 할당하고 싶은 : 당신이 ?auto.arima 보면, 당신이 stats::arima와 같은 개체를 반환 알게 될 것이다

p=1, d=1, q=0, P=0, D=1, Q=1 

답변

3

. ?arima을 자세히 살펴보면 원하는 정보가 $model에서 찾을 수 있음을 알 수 있습니다. $model의 세부 사항은 ?KalmanLike에서 읽을 수 있습니다 :

phi, theta: numeric vectors of length >= 0 giving AR and MA parameters. 

    Delta: vector of differencing coefficients, so an ARMA model is 
      fitted to ‘y[t] - Delta[1]*y[t-1] - ...’. 

그래서, 당신이해야 할 :

p <- length(fit$model$phi) 
q <- length(fit$model$theta) 
d <- fit$model$Delta 

?auto.arima에서 : 또는

library(forecast) 
fit <- auto.arima(WWWusage) 

length(fit$model$phi) ## 1 
length(fit$model$theta) ## 1 
fit$model$Delta ## 1 

fit$coef 
#  ar1  ma1 
# 0.6503760 0.5255959 

(실제로는 더 나은), 당신은 $arma 값 :

를 참조 할 수 있습니다.
arma: A compact form of the specification, as a vector giving the 
     number of AR, MA, seasonal AR and seasonal MA coefficients, 
     plus the period and the number of non-seasonal and seasonal 
     differences. 

하지만 정확하게 일치시켜야합니다. 위의 예를 들어,이 : 표기법 ARIMA(p,d,q)(P,D,Q)[m]를 사용

fit$arma 
# [1] 1 1 0 0 1 1 0 

, 우리는 분명 프레젠테이션 이름 속성을 추가 할 수 있습니다

setNames(fit$arma, c("p", "q", "P", "Q", "m", "d", "D")) 
# p q P Q m d D 
# 1 1 0 0 1 1 0 
+0

감사합니다, 업데이트 된 버전이 정확히 내가 무엇을 찾고 있었다! – user1723699