Allows to generate trading day regressors (as many as defined groups), taking
into account 7 or less different types of days, from Monday to Sunday, and
specific holidays,which are to defined beforehand in a calendar using the
functions national_calendar,weighted_calendar or Chained_calendar.
Usage
calendar_td(
calendar = national_calendar(),
frequency,
start,
length,
s,
groups = c(1, 2, 3, 4, 5, 6, 0),
holiday = 7,
contrasts = TRUE
)Arguments
- calendar
The calendar containing the required holidays
- frequency
Frequency of the series, number of periods per year (12, 4, 3, 2...)
- start, length
First date (array with the first year and the first period, for instance
c(1980, 1)) and number of periods of the output variables. Can also be provided with thesargument- s
time series used to get the dates for the trading days variables. If supplied the parameters
frequency,startandlengthare ignored.- groups
Groups of days. The length of the array must be 7. It indicates to what group each week day belongs. The first item corresponds to Mondays and the last one to Sundays. The group used for contrasts (usually Sundays) is identified by 0. The other groups are identified by 1, 2,... n (<= 6). For instance, usual trading days are defined by c(1, 2, 3, 4, 5, 6, 0), week days by c(1, 1, 1, 1, 1, 0, 0), week days, Saturdays, Sundays by c(1, 1, 1, 1, 1, 2, 0) etc.
- holiday
Day to aggregate holidays with. (holidays are considered as that day). 1 for Monday... 7 for Sunday. Doesn't necessary belong to the 0-group.
- contrasts
If true, the variables are defined by contrasts with the 0-group. Otherwise, raw number of days is provided.
Value
Time series (object of class c("ts","mts","matrix"))
corresponding to each group, starting with the 0-group
(contrasts = FALSE) or the 1-group (contrasts = TRUE).
Details
Aggregated values for monthly or quarterly are the numbers of days belonging
to a given group, holidays are all summed together in of those groups.
Contrasts are the differences between the number of days in a given group
(1 to 6) and the number of days in the reference group (0).
Regressors are corrected for long-term mean if contrasts = TRUE.
References
More information on calendar correction in JDemetra+ online documentation: https://doc.jdemetra.org/a-calendar-correction
Examples
BE <- national_calendar(list(
fixed_day(7, 21),
special_day("NEWYEAR"),
special_day("CHRISTMAS"),
special_day("MAYDAY"),
special_day("EASTERMONDAY"),
special_day("ASCENSION"),
special_day("WHITMONDAY"),
special_day("ASSUMPTION"),
special_day("ALLSAINTSDAY"),
special_day("ARMISTICE")
))
calendar_td(BE, 12, c(1980, 1), 240,
holiday = 7, groups = c(1, 1, 1, 2, 2, 3, 0),
contrasts = FALSE
)
#> Error in .jcheck(silent = FALSE): java.lang.ExceptionInInitializerError