Background

Import Data

library(lubridate)
## Warning: package 'lubridate' was built under R version 4.0.2
## 
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
## 
##     date, intersect, setdiff, union
library(padr)
## Warning: package 'padr' was built under R version 4.0.2
library(tidyverse)
## Warning: replacing previous import 'vctrs::data_frame' by 'tibble::data_frame'
## when loading 'dplyr'
## ── Attaching packages ─────────────────────────────────────────────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.2     ✓ purrr   0.3.4
## ✓ tibble  3.0.1     ✓ dplyr   1.0.0
## ✓ tidyr   1.1.0     ✓ stringr 1.4.0
## ✓ readr   1.3.1     ✓ forcats 0.5.0
## Warning: package 'ggplot2' was built under R version 4.0.2
## Warning: package 'purrr' was built under R version 4.0.2
## ── Conflicts ────────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
## x lubridate::as.difftime() masks base::as.difftime()
## x lubridate::date()        masks base::date()
## x dplyr::filter()          masks stats::filter()
## x lubridate::intersect()   masks base::intersect()
## x dplyr::lag()             masks stats::lag()
## x lubridate::setdiff()     masks base::setdiff()
## x lubridate::union()       masks base::union()
library(dplyr)
library(ggplot2)
library(scales)
## 
## Attaching package: 'scales'
## The following object is masked from 'package:purrr':
## 
##     discard
## The following object is masked from 'package:readr':
## 
##     col_factor
library(forecast)
## Warning: package 'forecast' was built under R version 4.0.2
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
library(plotly)
## Warning: package 'plotly' was built under R version 4.0.2
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
#panggilnya pake  underscore _
# gunakan data train
fnb <- read_csv("data/data-train.csv")
## Parsed with column specification:
## cols(
##   transaction_date = col_datetime(format = ""),
##   receipt_number = col_character(),
##   item_id = col_character(),
##   item_group = col_character(),
##   item_major_group = col_character(),
##   quantity = col_double(),
##   price_usd = col_double(),
##   total_usd = col_double(),
##   payment_type = col_character(),
##   sales_type = col_character()
## )
head(fnb)

Data Preprocessing

Tentukan langkah-langkah yang akan dilakukan dalam Data Preprocessing:

Do you need to round the datetime into hour or minutes?

gunakan function floor_date() -> dari lubridate

data_clean <- fnb %>%
   mutate(datetime = floor_date(transaction_date, unit = "hour"))
head(data_clean)

Do you need to aggregate/summarise the number of visitors before doing time series padding?

data_agg <- data_clean %>% 
   group_by(datetime) %>% 
   summarise(visitor = n_distinct(receipt_number))
## `summarise()` ungrouping output (override with `.groups` argument)
tail(data_agg)

group_by(datetime), summarise(visitor = n_distinct(receipt_number)) hasil agregasi : datetime visitor

When is the start and the end of the time interval for time series padding?

data_pad <- data_agg %>% 
   pad(start_val = min(data_agg$datetime), end_val = max(data_agg$datetime)) 
## pad applied on the interval: hour
# try to find out start time 
head(data_pad)
# try to find out end time
tail(data_pad)

Do you need to replace NA value?

# showing how many row  have missing data
anyNA(data_pad)
## [1] TRUE

Because we have any missing data, NA data will be replaced by null

data_pad <- data_pad %>% 
   mutate(visitor = replace_na(visitor, 0))
head(data_pad)
data_pad <- data_pad %>% 
   filter(hour(datetime) %in% c(10:22))

When is the start and the end of the time interval for time series padding?

  • filter datetime yang hour nya dari 10 sd 22 # Seasonality Analysis
data_ts <-  ts(data = data_pad$visitor, frequency = 13)

Can you decompose the time series into the observed data, trend, hourly seasonality, weekly seasonality, and the residuals?

  • Decompose single seasonality
data_ts %>% 
   decompose()
## $x
## Time Series:
## Start = c(1, 1) 
## End = c(80, 10) 
## Frequency = 13 
##    [1] 16 38 27 29 44 50 66 70 63 63 10 17 18 32 21 40 36 36 41 68 61 62 54  7
##   [25] 13 20 35 23 30 31 44 55 66 47 49 54  5  9 10 13 12 15 19 27 20 39 54 57
##   [49] 52  7 14 13  9 12 16 22 23 35 71 57 54 35  4 14 28 22 29 25 26 30 35 47
##   [73] 48 58 33  2 10  9 14 16 21 20 34 40 60 57 53 41  0  0  0 13 19 24 29 26
##   [97] 45 43 46 54 44 14 21 32 30 30 26 31 32 27 41 74 65 66  8 10 18 16 22 21
##  [121] 25 37 41 50 62 56 46 14 13 13 18 14 18 16 17 26 27 51 48 43  9 12 20 14
##  [145] 13 15 26 27 36 46 52 48 40 12 11 26 25 20 20 21 26 34 58 61 41 40  8  6
##  [169] 18 21 14 23 21 23 30 47 42 62 37  0  0  0 11 22 17 26 21 44 57 40 51 49
##  [193] 13 14 18 27 30 23 27 20 26 51 64 59 43  4 15 23 22 21 36 33 42 39 48 56
##  [217] 58 40  8 11 17 18 11 22 23 28 37 54 61 56 42  7 15 17 13 17 15 21 29 30
##  [241] 42 54 49 39  3 10 16 16 25 17 17 22 33 35 48 49 44 11 11 26 12 18 17 24
##  [265] 26 26 52 32 43 32  0  0  0  4 24 28 17 21 27 39 60 38 52 13 16 16 18 19
##  [289] 25 24 29 27 55 47 60 63  5 11 18 21 17 19 16 11 15 41 68 70 37  5 10 20
##  [313] 32 21 21 22 28 33 31 64 51 41  3 16 12 18 26 18 27 28 33 53 40 42 40  9
##  [337]  5  3 12 10 20 23 19 42 39 47 31 39  2 10 16 17 17 23 15 26 31 34 56 58
##  [361] 34  0  0  0  6 22 16 18 24 32 57 61 52 46  4  8 30 26 21 21 29 38 34 37
##  [385] 66 61 41  5 11 17 24 21 14 21 28 19 38 27 51 63  4 10 31 29 18 23 33 39
##  [409] 37 64 56 58 48 11 18 18 21 24 25 27 31 49 57 54 38 42 12  7 16 25 28 26
##  [433] 13 18 30 61 46 47 36  5  6 19 10 24 17  9 14 26 47 46 51 37  0  0  0  8
##  [457] 21 26 17 25 33 46 65 42 44 11 18 28 26 35 18 38 36 54 53 59 67 51 10 19
##  [481] 17 30 28 37 39 34 29 52 56 47 41  9 12  8 12 21 17 25 24 28 38 51 44 35
##  [505]  9  5  9 17 21 20 18 20 22 45 43 46 44  8 12 12 16 31 22 21 19 32 52 48
##  [529] 40 41  9  9 21 21 21 18 15 10 21 40 44 50 37  0  0  0 13 12 16 14 30 33
##  [553] 53 63 41 37  9 11 22 29 26 24 27 32 44 53 63 61 41 13 11 28 19 26 41 29
##  [577] 43 29 36 43 48 40  6  7 19 17  9 25 24 20 15 34 50 42 39  4 18 21 12 23
##  [601] 24 23 27 28 37 47 41 51  6 14 20  9 18 17 28 28 21 44 49 47 37 13  7 13
##  [625] 16 14 28 10 19 28 51 52 38 32  0  0  0  8 12 15 20 14 30 42 54 60 48  5
##  [649] 15 29 29 20 22 26 27 37 57 66 58 58  7 19 28 42 31 33 41 45 37 52 61 59
##  [673] 42  6 10 15 17 13 17 14 25 28 48 43 37 36  9 10 15 18 19 24 21 35 27 45
##  [697] 30 46 34 12 12 19 10 19 16 24 27 20 31 43 52 35  5  7 18 22 17 18 14 29
##  [721] 33 62 61 60 44  0  0  0  7 20 21 16 16 37 43 65 56 58  5 12 22 25 35 29
##  [745] 33 39 34 54 80 61 50  8 16 21 30 32 32 33 36 41 60 57 50 47 14 11 22 15
##  [769] 20 16 17 25 33 42 44 46 33  5  7 11 19 18 21 19 24 26 39 49 48 42  7 19
##  [793] 20 16 23 20 14 27 31 43 64 46 40  9 10 24 11 14 19 20 19 34 50 58 53 43
##  [817]  0  0  0  3 19 22 20 24 38 46 69 57 49 16 22 28 27 30 31 32 38 38 47 76
##  [841] 61 48  6 19 23 29 38 41 48 36 47 59 83 65 44  5  5 15 10 17 22  8 18 31
##  [865] 24 40 44 37  5 10 18 15  9 15 16 21 27 36 37 45 43  9 16 18 13 14 16 30
##  [889] 28 31 39 45 36 45  9 20 18 15 19 23 28 18 23 43 57 61 47  0  0  0  2 15
##  [913] 19 14 19 34 56 61 64 50  7 23 26 22 28 35 26 34 43 56 67 74 59  6 21 29
##  [937] 26 29 33 25 45 47 60 70 57 53  6 13 20 21 14 22 25 17 24 42 52 49 42  7
##  [961]  9 13 19 17 25 28 25 30 38 45 46 36  6  8 15 11  8 11 17 20 18 33 49 62
##  [985] 49  6  4  6 13 14 14  7 15 19 30 35 40 42  0  0  0  3 21 24 34 29 28 61
## [1009] 70 59 52  2 11 10 24 13 33 31 23 32 55 65 61 67 15 16 21 25 25 27 34 26
## [1033] 31 56 67 49 41
## 
## $seasonal
## Time Series:
## Start = c(1, 1) 
## End = c(80, 10) 
## Frequency = 13 
##    [1] -10.693318  -8.487865  -6.246385  -5.402179  -1.997939   3.400483
##    [7]  18.527714  25.556926  23.113888  15.379710 -22.232753 -18.240543
##   [13] -12.677739 -10.693318  -8.487865  -6.246385  -5.402179  -1.997939
##   [19]   3.400483  18.527714  25.556926  23.113888  15.379710 -22.232753
##   [25] -18.240543 -12.677739 -10.693318  -8.487865  -6.246385  -5.402179
##   [31]  -1.997939   3.400483  18.527714  25.556926  23.113888  15.379710
##   [37] -22.232753 -18.240543 -12.677739 -10.693318  -8.487865  -6.246385
##   [43]  -5.402179  -1.997939   3.400483  18.527714  25.556926  23.113888
##   [49]  15.379710 -22.232753 -18.240543 -12.677739 -10.693318  -8.487865
##   [55]  -6.246385  -5.402179  -1.997939   3.400483  18.527714  25.556926
##   [61]  23.113888  15.379710 -22.232753 -18.240543 -12.677739 -10.693318
##   [67]  -8.487865  -6.246385  -5.402179  -1.997939   3.400483  18.527714
##   [73]  25.556926  23.113888  15.379710 -22.232753 -18.240543 -12.677739
##   [79] -10.693318  -8.487865  -6.246385  -5.402179  -1.997939   3.400483
##   [85]  18.527714  25.556926  23.113888  15.379710 -22.232753 -18.240543
##   [91] -12.677739 -10.693318  -8.487865  -6.246385  -5.402179  -1.997939
##   [97]   3.400483  18.527714  25.556926  23.113888  15.379710 -22.232753
##  [103] -18.240543 -12.677739 -10.693318  -8.487865  -6.246385  -5.402179
##  [109]  -1.997939   3.400483  18.527714  25.556926  23.113888  15.379710
##  [115] -22.232753 -18.240543 -12.677739 -10.693318  -8.487865  -6.246385
##  [121]  -5.402179  -1.997939   3.400483  18.527714  25.556926  23.113888
##  [127]  15.379710 -22.232753 -18.240543 -12.677739 -10.693318  -8.487865
##  [133]  -6.246385  -5.402179  -1.997939   3.400483  18.527714  25.556926
##  [139]  23.113888  15.379710 -22.232753 -18.240543 -12.677739 -10.693318
##  [145]  -8.487865  -6.246385  -5.402179  -1.997939   3.400483  18.527714
##  [151]  25.556926  23.113888  15.379710 -22.232753 -18.240543 -12.677739
##  [157] -10.693318  -8.487865  -6.246385  -5.402179  -1.997939   3.400483
##  [163]  18.527714  25.556926  23.113888  15.379710 -22.232753 -18.240543
##  [169] -12.677739 -10.693318  -8.487865  -6.246385  -5.402179  -1.997939
##  [175]   3.400483  18.527714  25.556926  23.113888  15.379710 -22.232753
##  [181] -18.240543 -12.677739 -10.693318  -8.487865  -6.246385  -5.402179
##  [187]  -1.997939   3.400483  18.527714  25.556926  23.113888  15.379710
##  [193] -22.232753 -18.240543 -12.677739 -10.693318  -8.487865  -6.246385
##  [199]  -5.402179  -1.997939   3.400483  18.527714  25.556926  23.113888
##  [205]  15.379710 -22.232753 -18.240543 -12.677739 -10.693318  -8.487865
##  [211]  -6.246385  -5.402179  -1.997939   3.400483  18.527714  25.556926
##  [217]  23.113888  15.379710 -22.232753 -18.240543 -12.677739 -10.693318
##  [223]  -8.487865  -6.246385  -5.402179  -1.997939   3.400483  18.527714
##  [229]  25.556926  23.113888  15.379710 -22.232753 -18.240543 -12.677739
##  [235] -10.693318  -8.487865  -6.246385  -5.402179  -1.997939   3.400483
##  [241]  18.527714  25.556926  23.113888  15.379710 -22.232753 -18.240543
##  [247] -12.677739 -10.693318  -8.487865  -6.246385  -5.402179  -1.997939
##  [253]   3.400483  18.527714  25.556926  23.113888  15.379710 -22.232753
##  [259] -18.240543 -12.677739 -10.693318  -8.487865  -6.246385  -5.402179
##  [265]  -1.997939   3.400483  18.527714  25.556926  23.113888  15.379710
##  [271] -22.232753 -18.240543 -12.677739 -10.693318  -8.487865  -6.246385
##  [277]  -5.402179  -1.997939   3.400483  18.527714  25.556926  23.113888
##  [283]  15.379710 -22.232753 -18.240543 -12.677739 -10.693318  -8.487865
##  [289]  -6.246385  -5.402179  -1.997939   3.400483  18.527714  25.556926
##  [295]  23.113888  15.379710 -22.232753 -18.240543 -12.677739 -10.693318
##  [301]  -8.487865  -6.246385  -5.402179  -1.997939   3.400483  18.527714
##  [307]  25.556926  23.113888  15.379710 -22.232753 -18.240543 -12.677739
##  [313] -10.693318  -8.487865  -6.246385  -5.402179  -1.997939   3.400483
##  [319]  18.527714  25.556926  23.113888  15.379710 -22.232753 -18.240543
##  [325] -12.677739 -10.693318  -8.487865  -6.246385  -5.402179  -1.997939
##  [331]   3.400483  18.527714  25.556926  23.113888  15.379710 -22.232753
##  [337] -18.240543 -12.677739 -10.693318  -8.487865  -6.246385  -5.402179
##  [343]  -1.997939   3.400483  18.527714  25.556926  23.113888  15.379710
##  [349] -22.232753 -18.240543 -12.677739 -10.693318  -8.487865  -6.246385
##  [355]  -5.402179  -1.997939   3.400483  18.527714  25.556926  23.113888
##  [361]  15.379710 -22.232753 -18.240543 -12.677739 -10.693318  -8.487865
##  [367]  -6.246385  -5.402179  -1.997939   3.400483  18.527714  25.556926
##  [373]  23.113888  15.379710 -22.232753 -18.240543 -12.677739 -10.693318
##  [379]  -8.487865  -6.246385  -5.402179  -1.997939   3.400483  18.527714
##  [385]  25.556926  23.113888  15.379710 -22.232753 -18.240543 -12.677739
##  [391] -10.693318  -8.487865  -6.246385  -5.402179  -1.997939   3.400483
##  [397]  18.527714  25.556926  23.113888  15.379710 -22.232753 -18.240543
##  [403] -12.677739 -10.693318  -8.487865  -6.246385  -5.402179  -1.997939
##  [409]   3.400483  18.527714  25.556926  23.113888  15.379710 -22.232753
##  [415] -18.240543 -12.677739 -10.693318  -8.487865  -6.246385  -5.402179
##  [421]  -1.997939   3.400483  18.527714  25.556926  23.113888  15.379710
##  [427] -22.232753 -18.240543 -12.677739 -10.693318  -8.487865  -6.246385
##  [433]  -5.402179  -1.997939   3.400483  18.527714  25.556926  23.113888
##  [439]  15.379710 -22.232753 -18.240543 -12.677739 -10.693318  -8.487865
##  [445]  -6.246385  -5.402179  -1.997939   3.400483  18.527714  25.556926
##  [451]  23.113888  15.379710 -22.232753 -18.240543 -12.677739 -10.693318
##  [457]  -8.487865  -6.246385  -5.402179  -1.997939   3.400483  18.527714
##  [463]  25.556926  23.113888  15.379710 -22.232753 -18.240543 -12.677739
##  [469] -10.693318  -8.487865  -6.246385  -5.402179  -1.997939   3.400483
##  [475]  18.527714  25.556926  23.113888  15.379710 -22.232753 -18.240543
##  [481] -12.677739 -10.693318  -8.487865  -6.246385  -5.402179  -1.997939
##  [487]   3.400483  18.527714  25.556926  23.113888  15.379710 -22.232753
##  [493] -18.240543 -12.677739 -10.693318  -8.487865  -6.246385  -5.402179
##  [499]  -1.997939   3.400483  18.527714  25.556926  23.113888  15.379710
##  [505] -22.232753 -18.240543 -12.677739 -10.693318  -8.487865  -6.246385
##  [511]  -5.402179  -1.997939   3.400483  18.527714  25.556926  23.113888
##  [517]  15.379710 -22.232753 -18.240543 -12.677739 -10.693318  -8.487865
##  [523]  -6.246385  -5.402179  -1.997939   3.400483  18.527714  25.556926
##  [529]  23.113888  15.379710 -22.232753 -18.240543 -12.677739 -10.693318
##  [535]  -8.487865  -6.246385  -5.402179  -1.997939   3.400483  18.527714
##  [541]  25.556926  23.113888  15.379710 -22.232753 -18.240543 -12.677739
##  [547] -10.693318  -8.487865  -6.246385  -5.402179  -1.997939   3.400483
##  [553]  18.527714  25.556926  23.113888  15.379710 -22.232753 -18.240543
##  [559] -12.677739 -10.693318  -8.487865  -6.246385  -5.402179  -1.997939
##  [565]   3.400483  18.527714  25.556926  23.113888  15.379710 -22.232753
##  [571] -18.240543 -12.677739 -10.693318  -8.487865  -6.246385  -5.402179
##  [577]  -1.997939   3.400483  18.527714  25.556926  23.113888  15.379710
##  [583] -22.232753 -18.240543 -12.677739 -10.693318  -8.487865  -6.246385
##  [589]  -5.402179  -1.997939   3.400483  18.527714  25.556926  23.113888
##  [595]  15.379710 -22.232753 -18.240543 -12.677739 -10.693318  -8.487865
##  [601]  -6.246385  -5.402179  -1.997939   3.400483  18.527714  25.556926
##  [607]  23.113888  15.379710 -22.232753 -18.240543 -12.677739 -10.693318
##  [613]  -8.487865  -6.246385  -5.402179  -1.997939   3.400483  18.527714
##  [619]  25.556926  23.113888  15.379710 -22.232753 -18.240543 -12.677739
##  [625] -10.693318  -8.487865  -6.246385  -5.402179  -1.997939   3.400483
##  [631]  18.527714  25.556926  23.113888  15.379710 -22.232753 -18.240543
##  [637] -12.677739 -10.693318  -8.487865  -6.246385  -5.402179  -1.997939
##  [643]   3.400483  18.527714  25.556926  23.113888  15.379710 -22.232753
##  [649] -18.240543 -12.677739 -10.693318  -8.487865  -6.246385  -5.402179
##  [655]  -1.997939   3.400483  18.527714  25.556926  23.113888  15.379710
##  [661] -22.232753 -18.240543 -12.677739 -10.693318  -8.487865  -6.246385
##  [667]  -5.402179  -1.997939   3.400483  18.527714  25.556926  23.113888
##  [673]  15.379710 -22.232753 -18.240543 -12.677739 -10.693318  -8.487865
##  [679]  -6.246385  -5.402179  -1.997939   3.400483  18.527714  25.556926
##  [685]  23.113888  15.379710 -22.232753 -18.240543 -12.677739 -10.693318
##  [691]  -8.487865  -6.246385  -5.402179  -1.997939   3.400483  18.527714
##  [697]  25.556926  23.113888  15.379710 -22.232753 -18.240543 -12.677739
##  [703] -10.693318  -8.487865  -6.246385  -5.402179  -1.997939   3.400483
##  [709]  18.527714  25.556926  23.113888  15.379710 -22.232753 -18.240543
##  [715] -12.677739 -10.693318  -8.487865  -6.246385  -5.402179  -1.997939
##  [721]   3.400483  18.527714  25.556926  23.113888  15.379710 -22.232753
##  [727] -18.240543 -12.677739 -10.693318  -8.487865  -6.246385  -5.402179
##  [733]  -1.997939   3.400483  18.527714  25.556926  23.113888  15.379710
##  [739] -22.232753 -18.240543 -12.677739 -10.693318  -8.487865  -6.246385
##  [745]  -5.402179  -1.997939   3.400483  18.527714  25.556926  23.113888
##  [751]  15.379710 -22.232753 -18.240543 -12.677739 -10.693318  -8.487865
##  [757]  -6.246385  -5.402179  -1.997939   3.400483  18.527714  25.556926
##  [763]  23.113888  15.379710 -22.232753 -18.240543 -12.677739 -10.693318
##  [769]  -8.487865  -6.246385  -5.402179  -1.997939   3.400483  18.527714
##  [775]  25.556926  23.113888  15.379710 -22.232753 -18.240543 -12.677739
##  [781] -10.693318  -8.487865  -6.246385  -5.402179  -1.997939   3.400483
##  [787]  18.527714  25.556926  23.113888  15.379710 -22.232753 -18.240543
##  [793] -12.677739 -10.693318  -8.487865  -6.246385  -5.402179  -1.997939
##  [799]   3.400483  18.527714  25.556926  23.113888  15.379710 -22.232753
##  [805] -18.240543 -12.677739 -10.693318  -8.487865  -6.246385  -5.402179
##  [811]  -1.997939   3.400483  18.527714  25.556926  23.113888  15.379710
##  [817] -22.232753 -18.240543 -12.677739 -10.693318  -8.487865  -6.246385
##  [823]  -5.402179  -1.997939   3.400483  18.527714  25.556926  23.113888
##  [829]  15.379710 -22.232753 -18.240543 -12.677739 -10.693318  -8.487865
##  [835]  -6.246385  -5.402179  -1.997939   3.400483  18.527714  25.556926
##  [841]  23.113888  15.379710 -22.232753 -18.240543 -12.677739 -10.693318
##  [847]  -8.487865  -6.246385  -5.402179  -1.997939   3.400483  18.527714
##  [853]  25.556926  23.113888  15.379710 -22.232753 -18.240543 -12.677739
##  [859] -10.693318  -8.487865  -6.246385  -5.402179  -1.997939   3.400483
##  [865]  18.527714  25.556926  23.113888  15.379710 -22.232753 -18.240543
##  [871] -12.677739 -10.693318  -8.487865  -6.246385  -5.402179  -1.997939
##  [877]   3.400483  18.527714  25.556926  23.113888  15.379710 -22.232753
##  [883] -18.240543 -12.677739 -10.693318  -8.487865  -6.246385  -5.402179
##  [889]  -1.997939   3.400483  18.527714  25.556926  23.113888  15.379710
##  [895] -22.232753 -18.240543 -12.677739 -10.693318  -8.487865  -6.246385
##  [901]  -5.402179  -1.997939   3.400483  18.527714  25.556926  23.113888
##  [907]  15.379710 -22.232753 -18.240543 -12.677739 -10.693318  -8.487865
##  [913]  -6.246385  -5.402179  -1.997939   3.400483  18.527714  25.556926
##  [919]  23.113888  15.379710 -22.232753 -18.240543 -12.677739 -10.693318
##  [925]  -8.487865  -6.246385  -5.402179  -1.997939   3.400483  18.527714
##  [931]  25.556926  23.113888  15.379710 -22.232753 -18.240543 -12.677739
##  [937] -10.693318  -8.487865  -6.246385  -5.402179  -1.997939   3.400483
##  [943]  18.527714  25.556926  23.113888  15.379710 -22.232753 -18.240543
##  [949] -12.677739 -10.693318  -8.487865  -6.246385  -5.402179  -1.997939
##  [955]   3.400483  18.527714  25.556926  23.113888  15.379710 -22.232753
##  [961] -18.240543 -12.677739 -10.693318  -8.487865  -6.246385  -5.402179
##  [967]  -1.997939   3.400483  18.527714  25.556926  23.113888  15.379710
##  [973] -22.232753 -18.240543 -12.677739 -10.693318  -8.487865  -6.246385
##  [979]  -5.402179  -1.997939   3.400483  18.527714  25.556926  23.113888
##  [985]  15.379710 -22.232753 -18.240543 -12.677739 -10.693318  -8.487865
##  [991]  -6.246385  -5.402179  -1.997939   3.400483  18.527714  25.556926
##  [997]  23.113888  15.379710 -22.232753 -18.240543 -12.677739 -10.693318
## [1003]  -8.487865  -6.246385  -5.402179  -1.997939   3.400483  18.527714
## [1009]  25.556926  23.113888  15.379710 -22.232753 -18.240543 -12.677739
## [1015] -10.693318  -8.487865  -6.246385  -5.402179  -1.997939   3.400483
## [1021]  18.527714  25.556926  23.113888  15.379710 -22.232753 -18.240543
## [1027] -12.677739 -10.693318  -8.487865  -6.246385  -5.402179  -1.997939
## [1033]   3.400483  18.527714  25.556926  23.113888  15.379710
## 
## $trend
## Time Series:
## Start = c(1, 1) 
## End = c(80, 10) 
## Frequency = 13 
##    [1]       NA       NA       NA       NA       NA       NA 39.30769 40.53846
##    [9] 39.23077 40.23077 40.76923 40.15385 39.46154 39.61538 38.92308 38.84615
##   [17] 38.15385 37.92308 37.61538 37.76923 38.00000 38.15385 37.38462 37.00000
##   [25] 37.61538 38.69231 38.53846 37.46154 36.46154 36.46154 36.30769 36.00000
##   [33] 35.23077 33.53846 32.69231 31.53846 30.61538 29.30769 26.61538 24.53846
##   [41] 25.07692 25.69231 25.53846 25.69231 26.07692 26.30769 26.00000 26.00000
##   [49] 26.07692 26.30769 26.00000 27.15385 29.61538 29.84615 29.61538 28.30769
##   [57] 28.07692 28.07692 29.23077 30.23077 31.53846 32.23077 32.53846 33.07692
##   [65] 33.07692 31.23077 30.53846 30.84615 30.69231 30.53846 30.23077 28.76923
##   [73] 28.15385 27.15385 26.84615 26.38462 26.69231 27.07692 28.07692 28.76923
##   [81] 28.38462 29.00000 28.84615 28.07692 27.38462 27.30769 27.53846 27.76923
##   [89] 28.46154 27.84615 28.23077 26.92308 26.07692 26.15385 26.38462 27.46154
##   [97] 29.07692 31.53846 32.84615 33.69231 33.84615 34.00000 34.46154 33.07692
##  [105] 32.92308 35.07692 35.92308 37.61538 37.15385 36.30769 35.23077 34.15385
##  [113] 33.53846 33.15385 32.69231 33.07692 34.15385 34.84615 33.92308 33.23077
##  [121] 31.69231 32.15385 32.38462 32.00000 32.15385 31.53846 31.30769 30.61538
##  [129] 29.07692 27.92308 26.15385 25.30769 24.69231 24.46154 24.07692 24.00000
##  [137] 24.53846 24.23077 24.15385 23.92308 24.69231 25.46154 26.23077 27.69231
##  [145] 27.76923 27.76923 27.53846 27.76923 27.69231 28.15385 29.00000 29.53846
##  [153] 29.92308 29.53846 29.46154 29.30769 30.23077 30.92308 30.38462 30.38462
##  [161] 30.07692 29.69231 29.07692 28.76923 28.30769 28.53846 28.53846 28.30769
##  [169] 28.00000 27.15385 25.69231 27.30769 27.07692 26.46154 26.00000 24.61538
##  [177] 23.84615 24.46154 24.00000 24.38462 24.23077 25.30769 26.07692 25.92308
##  [185] 25.07692 26.00000 27.00000 28.07692 29.46154 30.69231 31.30769 31.76923
##  [193] 31.84615 31.76923 30.38462 29.92308 31.76923 32.38462 31.92308 31.23077
##  [201] 31.30769 31.69231 31.30769 30.61538 31.61538 32.07692 33.76923 34.76923
##  [209] 34.53846 33.92308 33.84615 33.61538 33.92308 33.61538 33.15385 32.84615
##  [217] 32.07692 31.00000 30.23077 29.15385 29.00000 29.46154 29.84615 29.69231
##  [225] 29.84615 29.76923 30.07692 30.07692 29.69231 30.15385 29.61538 29.46154
##  [233] 29.53846 29.00000 28.07692 27.53846 27.00000 26.76923 26.46154 26.07692
##  [241] 26.00000 26.23077 26.84615 27.00000 26.69231 26.15385 26.38462 25.84615
##  [249] 25.38462 25.38462 25.76923 26.38462 26.46154 27.23077 26.92308 26.38462
##  [257] 26.38462 26.92308 27.23077 26.69231 28.00000 26.76923 26.30769 25.38462
##  [265] 24.53846 23.69231 21.69231 21.07692 21.53846 22.38462 21.84615 21.46154
##  [273] 21.53846 20.53846 22.69231 22.30769 23.84615 24.84615 26.07692 27.30769
##  [281] 28.38462 28.00000 27.76923 28.30769 28.92308 28.92308 30.15385 29.15385
##  [289] 30.84615 31.69231 31.07692 30.69231 30.84615 31.07692 30.92308 30.46154
##  [297] 29.84615 28.46154 27.53846 26.46154 28.07692 28.84615 26.84615 26.84615
##  [305] 26.76923 26.92308 27.76923 28.07692 28.23077 28.69231 30.00000 31.38462
##  [313] 30.61538 30.30769 28.84615 29.15385 29.00000 29.46154 28.84615 27.76923
##  [321] 28.15385 27.92308 28.30769 28.30769 28.30769 30.00000 28.15385 27.46154
##  [329] 27.38462 27.84615 27.00000 26.30769 25.84615 24.61538 24.76923 24.46154
##  [337] 23.76923 24.46154 23.38462 23.92308 23.07692 23.00000 22.46154 22.84615
##  [345] 23.84615 24.23077 24.76923 25.00000 24.38462 24.92308 24.07692 23.69231
##  [353] 24.38462 26.46154 26.07692 25.92308 25.15385 23.92308 23.07692 23.46154
##  [361] 22.92308 23.15385 23.00000 23.07692 24.84615 25.23077 24.76923 25.69231
##  [369] 26.00000 26.61538 28.92308 30.46154 30.38462 30.76923 31.61538 32.69231
##  [377] 32.84615 31.30769 31.69231 32.38462 32.00000 32.07692 32.30769 31.30769
##  [385] 31.15385 31.15385 30.61538 30.00000 29.23077 28.07692 28.15385 25.15385
##  [393] 24.38462 26.07692 26.00000 25.92308 27.00000 27.38462 27.15385 27.84615
##  [401] 28.76923 29.61538 31.00000 33.00000 35.23077 35.76923 34.61538 35.15385
##  [409] 35.76923 34.76923 34.15385 34.61538 34.76923 34.30769 33.69231 34.61538
##  [417] 34.07692 33.92308 32.38462 31.92308 32.00000 31.15385 31.00000 31.30769
##  [425] 31.61538 31.69231 30.61538 29.61538 28.15385 28.46154 27.84615 28.53846
##  [433] 28.07692 27.53846 27.46154 27.69231 26.53846 26.23077 25.53846 25.23077
##  [441] 24.92308 24.61538 23.53846 23.53846 23.84615 23.92308 23.53846 23.07692
##  [449] 21.61538 21.46154 21.23077 21.92308 22.53846 23.38462 23.92308 23.84615
##  [457] 25.30769 24.61538 25.15385 26.00000 27.38462 29.53846 30.92308 32.00000
##  [465] 31.38462 33.00000 33.84615 35.46154 36.00000 35.53846 37.46154 38.00000
##  [473] 37.92308 38.00000 37.15385 37.46154 36.92308 38.38462 38.46154 38.30769
##  [481] 36.38462 36.30769 36.07692 34.53846 33.76923 33.69231 33.15385 32.46154
##  [489] 31.07692 30.53846 29.00000 27.92308 27.15385 27.07692 26.00000 25.61538
##  [497] 25.38462 24.92308 24.92308 24.38462 24.46154 24.84615 24.84615 25.07692
##  [505] 24.53846 24.23077 23.76923 24.30769 23.69231 23.84615 24.53846 24.46154
##  [513] 25.00000 25.23077 25.15385 25.92308 26.07692 26.30769 26.23077 27.00000
##  [521] 27.53846 27.92308 27.46154 27.23077 27.30769 27.07692 27.76923 28.15385
##  [529] 27.38462 27.07692 26.61538 25.92308 25.07692 24.15385 23.84615 24.61538
##  [537] 24.30769 23.61538 22.92308 21.30769 20.69231 20.00000 19.84615 19.76923
##  [545] 21.30769 22.23077 23.23077 24.69231 24.00000 24.00000 24.69231 25.53846
##  [553] 27.23077 28.46154 29.53846 30.15385 31.15385 31.30769 32.15385 32.15385
##  [561] 32.15385 33.69231 34.00000 34.30769 34.30769 34.76923 34.00000 34.00000
##  [569] 35.30769 35.46154 36.30769 35.15385 33.84615 32.30769 31.30769 31.23077
##  [577] 30.69231 30.38462 29.69231 29.53846 28.23077 27.00000 26.61538 24.84615
##  [585] 23.76923 23.61538 24.15385 23.69231 23.61538 23.46154 24.30769 24.46154
##  [593] 24.07692 25.15385 25.07692 25.00000 25.53846 26.53846 26.76923 26.53846
##  [601] 26.46154 27.38462 27.53846 27.23077 27.15385 26.92308 26.53846 26.00000
##  [609] 26.38462 26.46154 25.92308 26.46154 26.61538 27.07692 26.00000 26.53846
##  [617] 26.00000 25.46154 26.00000 25.69231 26.53846 25.15385 24.46154 25.00000
##  [625] 25.53846 25.76923 25.07692 24.69231 23.69231 23.15385 22.15385 21.53846
##  [633] 21.38462 20.38462 21.15385 20.76923 20.92308 20.23077 20.38462 22.07692
##  [641] 23.30769 23.69231 24.84615 27.07692 28.69231 29.30769 29.84615 30.30769
##  [649] 31.30769 31.84615 33.00000 33.92308 33.76923 34.53846 34.69231 35.00000
##  [657] 34.92308 35.92308 36.76923 37.61538 38.76923 40.15385 40.15385 39.76923
##  [665] 39.38462 39.46154 38.23077 38.15385 37.46154 36.46154 34.53846 33.15385
##  [673] 31.92308 29.84615 28.30769 27.61538 27.30769 25.92308 24.23077 23.76923
##  [681] 24.00000 24.00000 24.00000 24.07692 24.53846 25.07692 25.61538 26.38462
##  [689] 26.30769 26.07692 25.07692 25.76923 25.61538 25.84615 26.00000 26.30769
##  [697] 25.69231 25.69231 25.07692 25.30769 24.69231 24.15385 23.07692 24.07692
##  [705] 24.53846 24.61538 24.07692 23.69231 23.61538 24.53846 24.38462 24.53846
##  [713] 23.76923 23.92308 24.92308 27.30769 28.69231 29.30769 30.00000 29.61538
##  [721] 29.07692 27.69231 26.53846 26.76923 27.00000 27.15385 26.15385 26.46154
##  [729] 25.00000 25.30769 25.00000 26.07692 26.46154 27.38462 29.07692 30.46154
##  [737] 31.61538 32.23077 33.53846 35.30769 35.07692 35.92308 37.07692 37.46154
##  [745] 36.84615 37.07692 37.38462 37.30769 37.69231 37.46154 37.69231 37.69231
##  [753] 37.46154 38.00000 38.46154 36.69231 35.84615 35.61538 36.07692 35.69231
##  [761] 35.76923 34.61538 33.69231 32.46154 31.23077 30.38462 29.76923 28.38462
##  [769] 27.38462 27.07692 26.00000 25.30769 25.00000 24.15385 24.46154 24.30769
##  [777] 24.69231 24.84615 24.76923 24.23077 24.00000 24.38462 24.53846 25.23077
##  [785] 25.38462 26.30769 27.00000 26.76923 27.15385 27.07692 26.69231 26.92308
##  [793] 27.30769 27.61538 28.76923 28.61538 28.46154 28.61538 27.92308 28.23077
##  [801] 27.84615 27.15385 27.07692 27.53846 26.92308 27.15385 27.69231 27.23077
##  [809] 27.76923 28.00000 27.30769 26.53846 24.69231 24.07692 24.46154 24.69231
##  [817] 24.69231 25.07692 25.38462 25.07692 25.92308 26.23077 26.69231 27.92308
##  [825] 29.61538 31.76923 33.61538 34.46154 35.15385 36.07692 37.15385 37.15385
##  [833] 37.23077 37.76923 38.07692 38.00000 37.23077 37.00000 36.61538 36.76923
##  [841] 37.38462 38.15385 39.38462 39.23077 39.92308 40.84615 41.38462 41.69231
##  [849] 41.38462 41.30769 40.23077 39.61538 38.15385 36.53846 35.07692 32.00000
##  [857] 30.61538 29.38462 26.69231 23.38462 21.76923 21.23077 21.23077 21.61538
##  [865] 21.84615 22.23077 21.61538 21.07692 21.69231 21.92308 21.61538 22.53846
##  [873] 22.30769 22.38462 22.84615 23.15385 23.61538 23.61538 23.46154 23.84615
##  [881] 23.92308 25.00000 25.53846 25.84615 26.07692 26.69231 26.00000 26.15385
##  [889] 26.15385 26.46154 26.46154 26.61538 27.00000 27.53846 27.38462 26.61538
##  [897] 26.00000 26.30769 27.23077 29.15385 29.30769 28.61538 27.07692 25.69231
##  [905] 24.69231 24.38462 24.07692 23.00000 23.07692 23.92308 24.92308 25.23077
##  [913] 25.46154 25.69231 26.23077 28.00000 30.00000 31.53846 32.53846 33.76923
##  [921] 34.69231 35.84615 36.53846 36.53846 37.00000 37.76923 38.46154 38.38462
##  [929] 38.23077 38.46154 38.76923 38.84615 38.69231 38.61538 39.46154 39.76923
##  [937] 40.07692 40.30769 39.00000 38.53846 38.53846 37.92308 37.23077 36.84615
##  [945] 35.69231 34.84615 34.84615 32.69231 30.92308 29.53846 28.15385 27.53846
##  [953] 26.69231 26.76923 26.46154 25.92308 25.76923 26.00000 26.23077 26.46154
##  [961] 27.07692 27.53846 27.23077 26.69231 26.46154 26.00000 25.92308 25.84615
##  [969] 26.00000 25.38462 24.69231 23.61538 22.76923 22.38462 21.46154 21.07692
##  [977] 21.38462 22.61538 23.61538 23.61538 23.30769 22.61538 22.76923 23.23077
##  [985] 23.46154 22.69231 22.30769 22.38462 22.15385 21.07692 19.38462 18.84615
##  [993] 18.38462 18.07692 17.61538 16.84615 17.38462 18.15385 20.23077 21.30769
## [1001] 22.00000 24.38462 27.07692 28.53846 29.30769 29.46154 30.30769 31.07692
## [1009] 32.69231 32.07692 32.76923 32.53846 32.07692 32.38462 31.92308 31.53846
## [1017] 31.69231 32.84615 33.84615 34.23077 35.07692 35.15385 36.07692 35.61538
## [1025] 35.84615 36.07692 36.00000 36.07692 36.23077 35.30769 33.30769       NA
## [1033]       NA       NA       NA       NA       NA
## 
## $random
## Time Series:
## Start = c(1, 1) 
## End = c(80, 10) 
## Frequency = 13 
##    [1]            NA            NA            NA            NA            NA
##    [6]            NA   8.164593452   3.904612926   0.655343209   7.389520424
##   [11]  -8.536477629  -4.913303335  -8.783799927   3.077933277  -9.435211806
##   [16]   7.400231232   3.248332498   0.074862346  -0.015867437  11.703054991
##   [21]  -2.556925535   0.732266286   1.235674270  -7.767246859  -6.374841796
##   [26]  -6.014569157   7.154856354  -5.973673344  -0.215153383  -0.059359810
##   [31]   9.690246961  15.599517178  12.241516529 -12.095387074  -6.806195253
##   [36]   7.081828116  -3.382631475  -2.067149488  -3.937646080  -0.845143646
##   [41]  -4.589057960  -4.445922614  -1.136282887   3.305631577  -9.477405899
##   [46]  -5.835406548   2.443074465   7.886112439  10.543366578   2.925060833
##   [51]   6.240542819  -1.476107619  -9.922066723  -9.358288729  -7.368999537
##   [56]  -0.905513656  -3.078983808   3.522594101  23.241516529   1.212305234
##   [61]  -0.652349099 -12.610479576  -6.305708398  -0.836380258   7.600815458
##   [66]   1.462548661   6.949403579   0.400231232   0.709870959   1.459477730
##   [71]   1.368747947  -0.296945009  -5.710771689   7.732266286  -9.225864191
##   [76]  -2.151862244   1.548235127  -5.399184542  -3.383605185  -4.281365652
##   [81]  -1.138230306  -3.597821348   7.151785423   8.522594101  14.087670375
##   [86]   4.135382157   2.347650901  -2.148941115  -6.228785321  -9.605611027
##   [91] -15.553030696  -3.229759031   1.410942040   4.092538924   8.017563267
##   [96]   0.536400807  12.522594101  -7.066175779 -12.403079381  -2.806195253
##  [101]  -5.225864191   2.232753141   4.779004358  11.600815458   7.770240969
##  [106]   3.410942040  -3.676691845  -1.213205964  -3.155906885 -12.708175129
##  [111] -12.758483471  14.289228311   8.347650901  17.466443501  -2.459554552
##  [116]  -4.836380258  -3.476107619  -8.152835954  -3.435211806  -5.984384153
##  [121]  -1.290129041   6.844093115   5.214901794  -0.527714240   4.289228311
##  [126]   1.347650901  -0.687402653   5.617368525   2.163619742  -2.245338388
##  [131]   2.539471738  -2.819827191  -0.445922614  -3.059359810  -5.078983808
##  [136]  -1.400482822 -16.066175779   1.212305234   0.732266286   3.697212732
##  [141]   6.540445448   4.779004358   6.446969304  -2.998989800  -6.281365652
##  [146]  -6.522845691   3.863717113   1.228708500   4.907209486  -0.681560394
##  [151]  -2.556925535  -4.652349099  -5.302787268   4.694291602  -0.220995642
##  [156]   9.370046227   5.462548661  -2.435211806  -4.138230306  -3.982436733
##  [161]  -2.078983808   0.907209486  10.395362683   6.673843696 -10.421579868
##  [166]  -3.918171884   1.694291602  -4.067149488   2.677738535   4.539471738
##  [171]  -3.204442575   1.938692771  -0.674744425  -1.463599193   0.599517178
##  [176]   3.856901144  -7.403079381  14.424573978  -2.379710345  -2.151862244
##  [181]  -5.990226412 -12.629953773  -4.383605185   4.564788194  -1.830537999
##  [186]   5.402178652  -4.002060731  12.522594101   9.010747298 -16.249233228
##  [191]  -3.421579868   1.851058885   3.386599294   0.471312050   0.293123150
##  [196]   7.770240969   6.718634348  -3.138230306   0.479101729  -9.232829962
##  [201]  -8.708175129   0.779978068   7.135382157   5.270727824  -3.995094961
##  [206]  -5.844169936  -0.528687950   0.908507766  -1.845143646  -4.435211806
##  [211]   8.400231232   4.786794036  10.074862346   1.984132563  -3.681560394
##  [216]  -2.403079381   2.809189363  -6.379710345   0.001983910   0.086696665
##  [221]   0.677738535  -0.768220569 -10.358288729  -1.445922614  -1.443975194
##  [226]   0.228708500   3.522594101   5.395362683   5.750766772   2.732266286
##  [231]  -2.995094961  -0.228785321   3.702081281   0.677738535  -4.383605185
##  [236]  -2.050596421  -5.753614922  -0.367052117   4.536400807   0.522594101
##  [241]  -2.527714240   2.212305234  -0.960041407  -3.379710345  -1.459554552
##  [246]   2.086696665   2.293123150   0.847164046   8.103249733  -2.138230306
##  [251]  -3.367052117  -2.386676116   3.137978717 -10.758483471  -4.480002458
##  [256]  -0.498502945   2.235674270   6.309676217   2.009773588  11.985430843
##  [261]  -5.306682108  -0.281365652  -3.061307229   4.017563267   3.459477730
##  [266]  -1.092790514  11.779978068 -14.633848612  -1.652349099  -5.764325730
##  [271]   0.386599294  -3.220995642  -8.860723004  -5.845143646   9.795557425
##  [276]  11.938692771  -1.443975194  -1.848214577  -2.477405899  -6.835406548
##  [281]   6.058459080 -13.113887561   8.851058885   6.925060833   5.317465896
##  [286]  -0.245338388  -1.460528262  -1.665981037   0.400231232  -2.290129041
##  [291]  -0.078983808  -7.092790514   5.626131914  -9.633848612   5.963035516
##  [296]  17.158751193  -2.613400706   0.779004358   3.139276996   5.231779431
##  [301]  -2.589057960  -3.599768768  -5.443975194 -13.848214577 -15.169713591
##  [306]  -4.450791163  14.673843696  18.809189363  -6.610479576  -1.459554552
##  [311]  -1.759457181   1.293123150  12.077933277  -0.819827191  -1.599768768
##  [316]  -1.751667502   0.997939269   0.137978717 -16.373868086  10.673843696
##  [321]  -0.267733714  -2.302787268  -3.074939167   5.932850512  -3.629953773
##  [326]  -1.306682108   6.334018963  -3.215153383   5.017563267   2.151785423
##  [331]   2.599517178   8.164593452 -11.403079381  -5.729272176  -0.148941115
##  [336]   6.771214679  -0.528687950  -8.783799927  -0.691297492  -5.435211806
##  [341]   3.169462001   5.402178652  -1.463599193  15.753363332  -3.373868086
##  [346]  -2.787694766 -16.883118330  -1.379710345  -0.151862244   3.317465896
##  [351]   4.600815458   4.001010200   1.103249733   2.784846617  -5.674744425
##  [356]   2.074862346   2.445671024  -8.450791163   7.366151388  11.424573978
##  [361]  -4.302787268  -0.921093013  -4.759457181 -10.399184542  -8.152835954
##  [366]   5.257095886  -2.522845691  -2.290129041  -0.002060731   1.984132563
##  [371]   9.549208837   4.981536003  -1.498502945  -0.148941115  -5.382631475
##  [376]  -6.451764873   9.831584689   5.385625585  -2.204442575  -5.138230306
##  [381]   2.402178652   7.921016192  -1.708175129 -12.835406548   9.289228311
##  [386]   6.732266286  -4.995094961  -2.767246859   0.009773588   1.600815458
##  [391]   6.539471738   4.334018963  -4.138230306   0.325255575   3.997939269
##  [396] -10.323559745  -7.527714240 -25.941540920   0.732266286  19.774135809
##  [401]  -2.536477629  -1.374841796  12.677738535   6.693317892  -8.742904114
##  [406]  -6.522845691   3.786794036   5.844093115  -2.169713591  10.703054991
##  [411]  -3.710771689   0.270727824  -2.148941115  -1.074939167   2.548235127
##  [416]  -3.937646080  -2.383605185  -1.435211806  -1.138230306   0.479101729
##  [421]   0.997939269  14.445671024   7.472285760  -2.864617843 -16.729272176
##  [426]  -5.072018038   3.617368525  -4.374841796   0.523892381   7.231779431
##  [431]   8.641711271   3.707923540  -9.674744425  -7.540522270  -0.862021283
##  [436]  14.779978068  -6.095387074  -2.344656791  -4.918171884   2.001983910
##  [441]  -0.682534104   7.062353920  -2.845143646   8.949403579  -0.599768768
##  [446]  -9.520898271  -7.540522270  -0.477405899   6.856901144  -1.018463997
##  [451]   6.655343209  -0.302787268  -0.305708398  -5.144072565 -11.245338388
##  [456]  -5.152835954   4.180172809   7.631000463  -2.751667502   0.997939269
##  [461]   2.214901794  -2.066175779   8.519997542 -13.113887561  -2.764325730
##  [466]   0.232753141   2.394388973   5.216200073   0.693317892   7.949403579
##  [471] -13.215153383   5.402178652   0.074862346  12.599517178  -2.681560394
##  [476]  -4.018463997   6.963035516  -2.764325730  -6.228785321  -1.067149488
##  [481]  -6.706876850   4.385625585   0.410942040   8.707923540  10.632947883
##  [486]   2.305631577  -7.554328976   1.010747298  -0.633848612  -6.652349099
##  [491]  -3.379710345   3.309676217   3.086696665  -6.399184542  -3.306682108
##  [496]   3.872480502  -2.138230306   5.479101729   1.074862346   0.214901794
##  [501]  -4.989252702   0.596920619  -3.960041407  -5.456633422   6.694291602
##  [506]  -0.990226412  -2.091492234   3.385625585   5.795557425   2.400231232
##  [511]  -1.136282887  -2.463599193  -6.400482822   1.241516529  -7.710771689
##  [516]  -3.036964484   2.543366578   3.925060833   4.009773588  -2.322261465
##  [521]  -0.845143646  11.564788194   0.784846617  -0.828590579  -6.309753039
##  [526]   1.522594101   5.703054991  -5.710771689 -10.498502945  -1.456633422
##  [531]   4.617368525   1.317465896   8.600815458   7.539471738   5.641711271
##  [536]  -0.368999537  -3.905513656 -11.617445346  -5.323559745   0.164593452
##  [541]  -2.249233228   6.886112439   1.774135809   2.463522371  -3.067149488
##  [546]  -9.553030696   0.462548661  -4.204442575  -1.753614922  -4.597821348
##  [551]   7.305631577   4.061055640   7.241516529   8.981536003 -11.652349099
##  [556]  -8.533556499   0.078906987  -2.067149488   2.523892381   7.539471738
##  [561]   2.334018963  -3.445922614  -1.597821348  -0.309753039   6.291824871
##  [566]  -0.296945009   3.443074465   3.886112439  -9.687402653  -0.228785321
##  [571]  -7.067149488   5.523892381  -4.152835954   2.180172809  15.938692771
##  [576]   3.171409421  14.305631577  -4.785098206 -12.220021932 -12.095387074
##  [581]  -3.344656791  -2.379710345   1.617368525   0.394388973   7.908507766
##  [586]   4.077933277  -6.665981037   7.554077386   5.786794036  -1.463599193
##  [591] -12.708175129  -8.989252702   0.366151388  -6.267733714  -1.456633422
##  [596]   1.232753141  10.702081281   7.139276996  -4.075912877   4.949403579
##  [601]   3.784846617   1.017563267   1.459477730  -2.631252053  -8.681560394
##  [606]  -5.480002458  -8.652349099   9.620289655   1.848137756   5.779004358
##  [611]   6.754661612  -6.768220569  -0.127519498  -3.830537999   7.402178652
##  [616]   3.459477730  -8.400482822   0.010747298  -2.556925535  -1.806195253
##  [621]  -4.918171884  10.078906987   0.779004358   0.677738535   1.154856354
##  [626]  -3.281365652   9.169462001  -9.290129041  -2.694368423   1.445671024
##  [631]  10.318439606   4.904612926  -6.498502945  -3.764325730   1.078906987
##  [636]  -2.528687950  -8.245338388  -1.537451339   0.103249733  -0.830537999
##  [641]   2.094486344  -7.694368423   1.753363332  -3.604637317  -0.249233228
##  [646]   7.578420132   2.774135809  -3.074939167   1.932850512   9.831584689
##  [651]   6.693317892  -5.435211806  -5.522845691  -3.136282887  -5.694368423
##  [656]  -1.400482822   3.549208837   4.519997542  -1.883118330   5.004905039
##  [661]  -9.536477629  -2.913303335   0.523892381  12.924087123   0.103249733
##  [666]  -0.215153383   8.171409421   8.844093115  -3.862021283  -2.989252702
##  [671]   0.904612926   2.732266286  -5.302787268  -1.613400706  -0.067149488
##  [676]   0.062353920   0.385625585  -4.435211806  -0.984384153  -4.367052117
##  [681]   2.997939269   0.599517178   5.472285760  -6.633848612 -10.652349099
##  [686]  -4.456633422   5.617368525   1.855927435   1.370046227   2.616394815
##  [691]   2.410942040   4.477154309   0.786794036  11.151785423  -2.400482822
##  [696]   0.164593452 -21.249233228  -2.806195253  -6.456633422   8.925060833
##  [701]   5.548235127   7.523892381  -2.383605185   3.410942040  -2.292076460
##  [706]   4.786794036   4.921016192  -7.092790514 -11.143098856  -7.095387074
##  [711]   4.501497055  -4.918171884   3.463522371   1.317465896   5.754661612
##  [716]   5.385625585  -3.204442575  -5.061307229 -10.597821348   1.382554654
##  [721]   0.522594101  15.779978068   8.904612926  10.116881670   1.620289655
##  [726]  -4.921093013  -7.913303335 -13.783799927  -7.306682108   3.180172809
##  [731]   2.246385078  -4.674744425  -8.463599193   6.214901794  -4.604637317
##  [736]   8.981536003   1.270727824  10.389520424  -6.305708398  -5.067149488
##  [741]  -0.399184542  -0.229759031   6.410942040  -2.215153383   1.556024806
##  [746]   3.921016192  -6.785098206  -1.835406548  16.750766772   0.424573978
##  [751]  -3.072018038  -7.459554552  -3.220995642  -4.322261465   2.231779431
##  [756]   3.795557425   2.400231232   2.786794036   1.921016192   1.907209486
##  [761]   5.703054991  -3.172310151  -6.806195253  -0.841248807   5.001983910
##  [766]  -1.144072565   4.908507766  -2.691297492   1.103249733  -4.830537999
##  [771]  -3.597821348   1.690246961   4.599517178  -0.681560394  -6.018463997
##  [776]  -1.421579868  -7.072018038   2.386599294   0.471312050  -0.553030696
##  [781]   5.693317892   2.103249733   2.707923540  -0.828590579   0.613323884
##  [786]  -3.708175129  -6.527714240  -3.326156304  -2.267733714  -0.456633422
##  [791]   2.540445448  10.317465896   5.370046227  -0.922066723   2.718634348
##  [796]  -2.368999537  -9.059359810   0.382554654  -0.323559745  -3.758483471
##  [801]  10.596920619  -4.267733714  -2.456633422   3.694291602   1.317465896
##  [806]   9.523892381  -5.998989800  -4.742904114  -2.522845691  -2.597821348
##  [811]  -6.309753039   4.061055640   6.779978068   8.366151388   5.424573978
##  [816]   2.927981962  -2.459554552  -6.836380258 -12.706876850 -11.383605185
##  [821]   1.564788194   2.015615847  -1.290129041  -1.925137654   4.984132563
##  [826]  -4.296945009   9.827689849  -0.575426022  -1.533556499   2.155830064
##  [831]   3.086696665   3.523892381   0.462548661   0.718634348  -0.830537999
##  [836]  -0.597821348   2.767170038  -2.400482822  -8.143098856  13.673843696
##  [841]   0.501497055  -5.533556499 -11.151862244  -1.990226412  -4.245338388
##  [846]  -1.152835954   5.103249733   5.554077386  12.017563267  -3.309753039
##  [851]   3.368747947   0.856901144  19.289228311   5.347650901  -6.456633422
##  [856]  -4.767246859  -7.374841796  -1.706876850  -5.998989800   2.103249733
##  [861]   6.477154309  -7.828590579  -1.232829962   5.984132563 -16.373868086
##  [866]  -7.787694766  -0.729272176   0.543366578   5.540445448   6.317465896
##  [871]   9.062353920   3.154856354  -4.819827191  -1.138230306  -1.443975194
##  [876]  -0.155906885  -0.015867437  -6.143098856 -12.018463997  -1.960041407
##  [881]   3.697212732   6.232753141   8.702081281   4.831584689  -2.383605185
##  [886]  -4.204442575  -3.753614922   9.248332498   3.844093115   1.137978717
##  [891]  -5.989252702  -7.172310151 -14.113887561   2.081828116   3.848137756
##  [896]  11.625158204   4.677738535  -0.614374415   0.257095886   0.092538924
##  [901]   4.094486344  -8.617445346  -7.477405899  -1.220021932   6.750766772
##  [906]  13.501497055   7.543366578  -0.767246859  -4.836380258 -11.245338388
##  [911] -12.229759031  -1.742904114  -0.215153383  -6.290129041  -5.232829962
##  [916]   2.599517178   7.472285760   3.904612926   8.347650901   0.851058885
##  [921]  -5.459554552   5.394388973   2.139276996  -3.845143646  -0.512134883
##  [926]   3.477154309  -7.059359810  -2.386676116   1.368747947  -0.989252702
##  [931]   2.673843696  12.039958593   4.927981962 -10.382631475  -0.220995642
##  [936]   1.908507766  -3.383605185  -2.819827191   0.246385078  -8.136282887
##  [941]   8.459477730   5.676440255   4.241516529   7.596920619  -1.806195253
##  [946]   2.774135809  -6.613400706  -1.451764873   1.754661612   2.154856354
##  [951]  -5.665981037   0.707923540   3.709870959  -7.771291500  -5.862021283
##  [956]  -2.450791163   0.673843696  -0.113887561   0.389520424   2.771214679
##  [961]   0.163619742  -1.860723004   2.462548661  -1.204442575   4.784846617
##  [966]   7.402178652   1.074862346   0.753363332  -6.527714240  -5.941540920
##  [971]  -1.806195253  -2.995094961   5.463522371   3.855927435   6.216200073
##  [976]   0.616394815  -4.896750267  -5.368999537  -1.213205964  -1.617445346
##  [981]  -8.708175129  -8.143098856   0.673843696  15.655343209  10.158751193
##  [986]   5.540445448  -0.067149488  -3.706876850   1.539471738   1.410942040
##  [991]   0.861769694  -6.443975194  -1.386676116  -2.477405899  -6.143098856
##  [996]  -7.403079381  -0.498502945   8.466443501   2.001983910  -3.067149488
## [1001]  -9.322261465 -10.691297492   2.410942040   1.707923540  10.094486344
## [1006]   1.536400807  -5.708175129  11.395362683  11.750766772   3.809189363
## [1011]   3.851058885  -8.305708398  -2.836380258  -9.706876850   2.770240969
## [1016] -10.050596421   7.554077386   3.556024806  -8.848214577  -5.631252053
## [1021]   1.395362683   4.289228311   1.809189363  16.004905039   1.386599294
## [1026]  -1.836380258  -2.322261465  -0.383605185  -2.742904114  -2.061307229
## [1031]   6.094486344            NA            NA            NA            NA
## [1036]            NA            NA
## 
## $figure
##  [1] -10.693318  -8.487865  -6.246385  -5.402179  -1.997939   3.400483
##  [7]  18.527714  25.556926  23.113888  15.379710 -22.232753 -18.240543
## [13] -12.677739
## 
## $type
## [1] "additive"
## 
## attr(,"class")
## [1] "decomposed.ts"

Compared multiple time series decomposition approach

  • Decompose Multi seasonality
msts_data <- data_pad$visitor %>% msts(seasonal.periods = c(13, 13*7))
msts_data %>% head(13*7*4) %>% mstl() %>% autoplot()  

Model Fitting and Evaluation

Do you need to do cross validation before doing time series analysis?

yes, train and test from data train

How do you split the data into training and testing dataset?

train_msts <- head(msts_data, length(msts_data) - 13*7)
test_msts <- tail(msts_data,  13*7)

# # subset to more recent period
# train_msts <- tail(train_msts, 13*7*4)
# autoplot(train_msts)

modelling using arima

arima_model <- train_msts %>% 
   stlm(method = "arima") %>% 
   forecast(h = 91)
plot(arima_model)

## forecast

# forecast
arima_fc <- forecast(object = arima_model, h=91)

evaluation (arima)

# evaluation
arima_eval <- accuracy(arima_fc$mean, test_msts)
arima_eval
##                 ME     RMSE      MAE MPE MAPE      ACF1 Theil's U
## Test set -2.127162 7.332962 5.656791 NaN  Inf 0.3444129         0

Can you visualize the actual vs estimated number of visitors?

visualisasi Forecast using ARIMA

msts_data %>% 
  autoplot(series = "actual") +
  autolayer(arima_fc$fitted, series = "train") +
  autolayer(arima_fc$mean, series = "test") +
  theme_minimal()

### modelling using tbats

tbats_model <- train_msts %>% 
   tbats(use.box.cox = FALSE, 
                  use.trend = TRUE, 
                  use.damped.trend = TRUE)
plot(tbats_model)

## Can you visualize the actual vs estimated number of visitors?

forecasting tbats

tbats_fc <- forecast(tbats_model, h=91)
plot(tbats_fc)

Evaluation TBATS model

tbats_eval <- accuracy(tbats_fc$mean, test_msts)
tbats_eval
##                 ME     RMSE      MAE  MPE MAPE      ACF1 Theil's U
## Test set -3.783676 7.953826 6.533778 -Inf  Inf 0.4875056         0

How many forecasting model will you use?

two, arima and tbats # Prediction Performance ### How to evaluate the model performance?

arima_eval
##                 ME     RMSE      MAE MPE MAPE      ACF1 Theil's U
## Test set -2.127162 7.332962 5.656791 NaN  Inf 0.3444129         0
tbats_eval
##                 ME     RMSE      MAE  MPE MAPE      ACF1 Theil's U
## Test set -3.783676 7.953826 6.533778 -Inf  Inf 0.4875056         0

visualisasi arima vs tbats vs actual

msts_data %>% 
  autoplot(series = "actual") +
  autolayer(arima_fc$fitted, series = "train") +
  autolayer(arima_fc$mean, series = "arima") +
   autolayer(tbats_fc$mean, series = "tbats") +
  theme_minimal()

data_test <- read_csv("data/data-test.csv")
## Parsed with column specification:
## cols(
##   datetime = col_datetime(format = ""),
##   visitor = col_logical()
## )

Submission

# forecast the target using model
forecast_mod <- forecast(arima_fc)

# create submission data 
submission <- data_test %>% 
   mutate(visitor=round(forecast_mod$mean %>% tail(91)))
write.csv(submission,"submission-adam.csv", row.names = F)

Conclusion

Does the model meet the autocorrelation assumption?

(Autocorrelation)

Box.test(arima_fc$residuals,type = "Ljung-Box")
## 
##  Box-Ljung test
## 
## data:  arima_fc$residuals
## X-squared = 0.0027996, df = 1, p-value = 0.9578

Where p-value < 0.05; reject H0, accept H1 It means there is no autocorrelation in the forecast errors.

What about the normality of residuals?

(Normality test)

set.seed(100)
shapiro.test(arima_fc$residuals)
## 
##  Shapiro-Wilk normality test
## 
## data:  arima_fc$residuals
## W = 0.99025, p-value = 6.452e-06

distribusi tidak normal, karena p-value < 0.05. ## If the assumptions are not met, what is the cause? how to handle that? maka harus dilakukan transformasi data menggunakan log()

hist(arima_fc$residual, breaks = 30)

## Reported interpretable hourly and weekly seasonality.

Based on seasonality when the highest visitors ?

submission %>% 
   arrange(-visitor)

The highest visitor on 2018-02-24 20:00:00 with 68 visitors

visualisasi seasonality

submission %>% 
   mutate(hour=hour(datetime),
          seasonal=visitor,
          wday=wday(datetime, label = T, abbr = T)) %>% 

ggplot(aes(x = hour, y = seasonal))+
   geom_col(aes(fill=wday))+
   labs(title = "Seasonality across hour and weekdays", x = "Hour", y="Visitors")+
   theme_minimal()+
   theme(legend.position = "right")

How do you interpret the seasonality? Describe the interpretation.

the highest visitor come to restaurant is on 20.00 WIB. also the highest day on Saturday