SHARE
TWEET

Untitled

a guest Jul 17th, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. get.best.arima <- function(rv, maxord = c(1,1,1,1,1,1))
  2. {
  3. best.aic <- 1e8
  4. n <- length(rv)
  5. for (p in 0:maxord[1]) for(d in 0:maxord[2]) for(q in 0:maxord[3])
  6. for (P in 0:maxord[4]) for(D in 0:maxord[5]) for(Q in 0:maxord[6])
  7. {
  8. fit <- arima(rv, order = c(p,d,q),
  9. seas = list(order = c(P,D,Q),
  10. frequency(rv)), method = "CSS")
  11. fit.aic <- -2 * fit$loglik + (log(n) + 1) * length(fit$coef)
  12. if (fit.aic < best.aic)
  13. {
  14. best.aic <- fit.aic
  15. best.fit <- fit
  16. best.model <- c(p,d,q,P,D,Q)
  17. }}
  18. list(best.aic, best.fit, best.model)
  19. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top