1

I am using the tbats() function in r to create a forecasting model.

I was wondering if anyone knew how to manually pass the ARMA(p,q) directly into the tbats() function?

edit: I apologize if the question was vague. In the docs for the package, the following argument explanation is printed:

"Additional arguments to be passed to auto.arima when choose an ARMA(p, q) model for the errors. (Note that xreg will be ignored, as will any arguments concerning seasonality and differencing, but arguments controlling the values of p and q will be used.)"

It clearly states that manually controlling the ARMA(p,q) can be done with an argument passed directly into the tbats() function. Does anyone know how to do this?

https://www.rdocumentation.org/packages/forecast/versions/7.3/topics/tbats

TrevUsesR
  • 115
  • 3
  • It would be easier to help you if you provided a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample data and code you're tried to make it clear what you are trying to do. – MrFlick Jul 05 '17 at 18:50

2 Answers2

0

Shortly, you cannot.

tbats is a hybrid algorithm so you should not try to think about building an ARMA model with it. The tbats function does the applying of the arma error terms automatically by the boolean parameter use.arma.errors=TRUE/FALSE, this tries to model better the residuals.

If you want to build an ARIMA model, you can use the auto.arima from forecast package.

Example about auto.arima

auto.arima(USJudgeRatings[,1], ic='aicc', stepwise=FALSE, start.p=3, start.q=1, max.p=3, max.q=3)

Example about tbats

omega<-USJudgeRatings[,1];p<-10; q<-2; phi<-3; 
tbats(omega, p,q, phi,use.arma.errors=TRUE)
BATS(0, {0,0}, 0.979, -)

Call: tbats(y = omega, use.box.cox = p, use.trend = q, use.damped.trend = phi, 
    use.arma.errors = TRUE)

Parameters
  Lambda: 0
  Alpha: -0.04239053
  Beta: 0.04362955
  Damping Parameter: 0.978616

Seed States:
         [,1]
[1,] 1.917976
[2,] 0.017468

Sigma: 0.1206409
AIC: 163.774

where my parameters p, q and phi stand for use.box.cox, use.trend and use.damped.trend.

Further Information


  1. There is an excellent demonstration about using the different models of forecast package here.

  2. Definition of Tbats is the following:

[Tbats] time series decomposition model consists of decomposing a time series into trend, seasonal, cyclical, and irregular components. Then each component is explicitly estimated and measured statistically. Each estimated component is then recombined in order to estimate a final model and calculate predictions going forward. A BATS model will then incorporate additional autoregressive and moving average components (p, q) to better model any leftover patterns presented in the model residuals. (Source)

hhh
  • 50,788
  • 62
  • 179
  • 282
  • 1
    I see. Thank you for the explanation. I guess I was confused -- in the docs it makes it seem like you can manually control the ARMA(p,q) elements of the function: "Additional arguments to be passed to auto.arima when choose an ARMA(p, q) model for the errors. (Note that xreg will be ignored, as will any arguments concerning seasonality and differencing, **but arguments controlling the values of p and q will be used**.)" – TrevUsesR Jul 06 '17 at 13:09
0

The ... argument of tbats will be passed to auto.arima, from the documentation (?tbats)

...: Additional arguments to be passed to ‘auto.arima’ when
      choose an ARMA(p, q) model for the errors. (Note that
      xreg will be ignored, as will any arguments concerning
      seasonality and differencing, but arguments controlling
      the values of p and q will be used.)

Looking at the documentation for auto.arima we see that there are arguments for setting values for p and q.

 auto.arima(y, d = NA, D = NA, max.p = 5, max.q = 5, max.P = 2,
   max.Q = 2, max.order = 5, max.d = 2, max.D = 1, start.p = 2,
   start.q = 2, start.P = 1, start.Q = 1, stationary = FALSE,
   seasonal = TRUE, ic = c("aicc", "aic", "bic"), stepwise = TRUE,
   trace = FALSE, approximation = (length(x) > 150 | frequency(x) > 12),
   truncate = NULL, xreg = NULL, test = c("kpss", "adf", "pp"),
   seasonal.test = c("ocsb", "ch"), allowdrift = TRUE, allowmean = TRUE,
   lambda = NULL, biasadj = FALSE, parallel = FALSE, num.cores = 2,
   x = y, ...)

So, for the work you're doing, added the arguments start.p, start.q, and trace to the tbats call to control the starting values and see the search.

The best model, in this example, is ARIMA(0, 0, 0) with zero mean. The BATS(0, {0,0}, 0.979, -) tells us the values of {p, q} = {0, 0} were selected.

library(forecast)

omega <- USJudgeRatings[,1]

tbats(y                = omega,
      use.box.cox      = TRUE,
      use.trend        = TRUE,
      use.damped.trend = TRUE,
      use.arma.errors  = TRUE,
      start.p = 3,
      start.q = 2,
      trace = TRUE)
# 
#  ARIMA(3,0,2) with non-zero mean : Inf
#  ARIMA(0,0,0) with non-zero mean : -55.63664
#  ARIMA(1,0,0) with non-zero mean : -53.50348
#  ARIMA(0,0,1) with non-zero mean : -53.47905
#  ARIMA(0,0,0) with zero mean     : -57.75828
#  ARIMA(1,0,1) with non-zero mean : -51.19495
# 
#  Best model: ARIMA(0,0,0) with zero mean     
# 
# BATS(0, {0,0}, 0.979, -)
# 
# Call: tbats(y = omega, use.box.cox = TRUE, use.trend = TRUE, use.damped.trend = TRUE, 
#     use.arma.errors = TRUE, start.p = 3, start.q = 2, trace = TRUE)
# 
# Parameters
#   Lambda: 0
#   Alpha: -0.04239053
#   Beta: 0.04362955
#   Damping Parameter: 0.978616
# 
# Seed States:
#          [,1]
# [1,] 1.917976
# [2,] 0.017468
# 
# Sigma: 0.1206409
# AIC: 163.774
Peter
  • 7,460
  • 2
  • 47
  • 68
  • Fantastic! Thank you very much. This was exactly what I was looking for. I wasn't including the 'trace = T' argument. I upvoted and check-marked you. However, my account is new. – TrevUsesR Jul 06 '17 at 15:05