(thanks to Rami Krispin - package author)

Data

data("AirPassengers")
AirPassengers
     Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
1949 112 118 132 129 121 135 148 148 136 119 104 118
1950 115 126 141 135 125 149 170 170 158 133 114 140
1951 145 150 178 163 172 178 199 199 184 162 146 166
1952 171 180 193 181 183 218 230 242 209 191 172 194
1953 196 196 236 235 229 243 264 272 237 211 180 201
1954 204 188 235 227 234 264 302 293 259 229 203 229
1955 242 233 267 269 270 315 364 347 312 274 237 278
1956 284 277 317 313 318 374 413 405 355 306 271 306
1957 315 301 356 348 355 422 465 467 404 347 305 336
1958 340 318 362 348 363 435 491 505 404 359 310 337
1959 360 342 406 396 420 472 548 559 463 407 362 405
1960 417 391 419 461 472 535 622 606 508 461 390 432

Time series

ts_plot(AirPassengers, line.mode = "lines+markers", Ygrid = T,
        Xtitle = "Month", Ytitle = "Value", slider = T)

Decomposition

ts_decompose(AirPassengers)

Seasonality

ts_seasonal(AirPassengers, type = "all", Ygrid = T)

Autocorrelation

ts_cor(AirPassengers)

Transformations

AirPassengersLogDiff <- diff(log(AirPassengers))
ts_plot(AirPassengersLogDiff, line.mode = "lines+markers", Ygrid = T,
        Xtitle = "Month", Ytitle = "Value", slider = T)
ts_cor(AirPassengersLogDiff)

Models & Forecasting

methods <- list(
  arima = list(
    method = "auto.arima",
    notes = "Arima",
    method_arg = list(
      lambda = "auto"
    )
  )
)

model <- train_model(
  input = AirPassengers,
  methods = methods,
  train_method = list(
    partitions = 4,
    sample.out = 12,
    space = 1
    #sample.in = 24
  ),
  horizon = 12,
  error = "MAPE"
)
Registered S3 method overwritten by 'quantmod':
  method            from
  as.zoo.data.frame zoo 
Registered S3 methods overwritten by 'forecast':
  method             from    
  fitted.fracdiff    fracdiff
  residuals.fracdiff fracdiff
# A tibble: 1 x 7
  model_id model     notes avg_mape avg_rmse `avg_coverage_80… `avg_coverage_95…
  <chr>    <chr>     <chr>    <dbl>    <dbl>             <dbl>             <dbl>
1 arima    auto.ari… Arima   0.0315     19.4             0.938             0.979
model$forecast$arima$model
Series: structure(c(112, 118, 132, 129, 121, 135, 148, 148, 136, 119,  104, 118, 115, 126, 141, 135, 125, 149, 170, 170, 158, 133, 114,  140, 145, 150, 178, 163, 172, 178, 199, 199, 184, 162, 146, 166,  171, 180, 193, 181, 183, 218, 230, 242, 209, 191, 172, 194, 196,  196, 236, 235, 229, 243, 264, 272, 237, 211, 180, 201, 204, 188,  235, 227, 234, 264, 302, 293, 259, 229, 203, 229, 242, 233, 267,  269, 270, 315, 364, 347, 312, 274, 237, 278, 284, 277, 317, 313,  318, 374, 413, 405, 355, 306, 271, 306, 315, 301, 356, 348, 355,  422, 465, 467, 404, 347, 305, 336, 340, 318, 362, 348, 363, 435,  491, 505, 404, 359, 310, 337, 360, 342, 406, 396, 420, 472, 548,  559, 463, 407, 362, 405, 417, 391, 419, 461, 472, 535, 622, 606,  508, 461, 390, 432), .Tsp = c(1949, 1960.91666666667, 12), class = "ts") 
ARIMA(0,1,1)(0,1,1)[12] 
Box Cox transformation: lambda= -0.2947156 

Coefficients:
          ma1     sma1
      -0.4355  -0.5847
s.e.   0.0908   0.0725

sigma^2 estimated as 5.855e-05:  log likelihood=451.6
AIC=-897.19   AICc=-897.01   BIC=-888.57
plot_model(model)
model$forecast$arima$forecast
         Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
Jan 1961       452.1515 426.2792 480.0937 413.3572 495.7930
Feb 1961       426.4011 398.9958 456.2936 385.4089 473.2196
Mar 1961       485.7606 449.8496 525.4722 432.2263 548.2023
Apr 1961       497.5488 457.2589 542.5570 437.6345 568.5258
May 1961       515.2679 470.0228 566.3156 448.1458 596.0016
Jun 1961       597.6026 539.4607 664.1222 511.6344 703.2367
Jul 1961       692.6413 618.5686 778.6153 583.4895 829.7533
Aug 1961       689.9635 612.6199 780.4343 576.1988 834.5832
Sep 1961       570.3328 506.9349 644.3856 477.0500 688.6576
Oct 1961       502.5756 446.4132 568.2355 419.9562 607.5178
Nov 1961       430.4898 382.6514 486.3652 360.1002 519.7685
Dec 1961       482.0485 424.9022 549.5528 398.1834 590.2752
plot_forecast(model$forecast$arima$forecast)