gen_outlier_matrix: Generate point outlier regression matrix

View source: R/gen_outlier_matrix.r

gen_outlier_matrixR Documentation

Generate point outlier regression matrix

Description

Generates a regression matrix of AO (point) outliers to be included in weekly modeling routines

Usage

gen_outlier_matrix(
  outlier_dates,
  this_week,
  this_year,
  forecast = 0,
  air_name = TRUE,
  return_xts = FALSE
)

Arguments

outlier_dates

Integer matrix - matrix of dates for point outliers

this_week

Numeric vector; Week of the year for each observation.

this_year

Numeric vector; Year of each observation.

forecast

Numeric scalar; Number of forecasts. Default: 0.

air_name

Logical scalar; If TRUE, names are formatted as they are in the fractional airline routine; otherwise format them as in movereg. Default: TRUE

return_xts

Logical scalar; return matrix as an xts time series object. Default is FALSE. If TRUE, this_week and this_year should be xts time series objects.

Value

Generate matrix of point outlier regressors, with column names that describe the individual regressors

Examples

ic_outlier_date <-
   matrix(c(30, 1992, 30, 1993, 52, 1993,  5, 1994,  3, 1996,
            38, 2001, 39, 2001, 40, 2001, 41, 2001, 42, 2001,
            43, 2001, 47, 2001, 48, 2001, 37, 2005, 38, 2005,
            39, 2005, 40, 2005, 41, 2005,  1, 2006,  2, 2007,
             4, 2008, 45, 2012, 35, 2017, 12, 2020, 13, 2020,
            14, 2020, 15, 2020, 16, 2020), ncol=2, byrow=TRUE)
ic_outlier_matrix_1992 <-
   gen_outlier_matrix(ic_outlier_date, ic_week, ic_year, 0,
                      return_xts = FALSE)
cc_outlier_dates_1992 <-
   matrix(c(30, 1992, 30, 1993, 52, 1993,  5, 1994,  3, 1996,
            38, 2001, 39, 2001, 40, 2001, 41, 2001, 42, 2001,
            43, 2001, 47, 2001, 48, 2001, 37, 2005, 38, 2005,
            39, 2005, 40, 2005, 41, 2005,  1, 2006,  2, 2007,
             4, 2008, 45, 2012, 35, 2017, 12, 2020, 13, 2020), ncol=2, byrow=TRUE)
cc_level_matrix_xts_1992 <-
   gen_level_outlier_matrix(cc_outlier_dates_1992, cc_week_xts, cc_year_xts, 0,
                            return_xts = TRUE)

bcmonsell/airutilities documentation built on May 16, 2022, 3:23 p.m.