get_seasonality_additive: Get seasonality period for a time series object

Description Usage Arguments Details Value Examples

View source: R/HELPER_get_seasonality_additive.R

Description

get_seasonality_additive is a function to get seasonality for a time series object and the seasonality is returned as a vector of integer values.

Usage

1
get_seasonality_additive(ts_object, top_num = 2)

Arguments

ts_object

A time series object containing the values for the column_of_interest, which has been created using the tstools::transform_data_to_ts_object

top_num

An int number to specify how many seasonality patterns that need to be detected, the default value is 2.

Details

The function will, for a time series object (mostly, one group of data), get seasonality pattern returned as a vector. The number of seasonality pattern detected is defined as a input parameter of the function, and it represents the top n significant seasonality pattern found.

Value

seasonality: A vector containing seasonality patterns discovered. For example, (12, 3). If the ts_object is monthly time series object, it means the seasonality is 12 months and 3 months.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
ts_object <- tstools::initialize_ts_forecast_data(
      data = dummy_gasprice,
      date_col = "year_month",
      col_of_interest = "gasprice",
      group_cols = c("state", "oil_company"),
      xreg_cols = c("spotprice", "gemprice")
   )%>%
   dplyr::filter(grouping == "state = New York   &   oil_company = CompanyB") %>%
   dplyr::select(period, col_of_interest, grouping) %>%
   tstools::transform_data_to_ts_object(seasonal_periods = 1)
get_seasonality_additive(ts_object, top_num = 2)

ing-bank/tsforecast documentation built on Sept. 18, 2020, 9:40 a.m.