Add a random-walk holiday model to a state specification.
This model allows each active day in a holiday window to move according to a random walk relative to the day's value the last time the holiday occurred.
AddFixedDateHoliday(state.specification = NULL,
holiday.name,
month,
day,
y,
sigma.prior = NULL,
initial.state.prior = NULL,
sdy = sd(as.numeric(y), na.rm = TRUE),
time0 = NULL,
days.before = 1,
days.after = 1)AddNthWeekdayInMonthHoliday(state.specification = NULL,
holiday.name,
month,
day.of.week,
which.week,
y,
sigma.prior = NULL,
initial.state.prior = NULL,
sdy = sd(as.numeric(y), na.rm = TRUE),
time0 = NULL,
days.before = 1,
days.after = 1)
AddLastWeekdayInMonthHoliday(state.specification = NULL,
holiday.name,
month,
day.of.week,
y,
sigma.prior = NULL,
initial.state.prior = NULL,
sdy = sd(as.numeric(y), na.rm = TRUE),
time0 = NULL,
days.before = 1,
days.after = 1)
NamedHolidays(except = NULL)
AddNamedHolidays(state.specification = NULL,
named.holidays = NamedHolidays(),
y,
sigma.prior = NULL,
initial.state.prior = NULL,
sdy = sd(as.numeric(y), na.rm = TRUE),
time0 = NULL,
days.before = 1,
days.after = 1)
A list of state components that you wish augment. If omitted, an empty list will be assumed.
A string that can be used to label the holiday in output.
A character vector containing one or more recognized holiday names.
The time series to be modeled, as a numeric vector
convertible to xts
. This state model assumes y
contains daily data.
An object created by SdPrior
describing the prior distribution for the standard deviation of the
random walk increments.
An object created using
NormalPrior
, describing the prior distribution
of the the initial state vector (at time 1).
The standard deviation of the series to be modeled. This
will be ignored if y
is provided, or if all the required
prior distributions are supplied directly.
An integer giving the number of days the influence of the holiday extends prior to the actual holiday.
An integer giving the number of days the influence of the holiday extends after the actual holiday.
A string naming the month in which the holiday occurs. Unambiguous partial matches are acceptable. Capitalize the first letter.
An integer specifying the day of the month on which the
FixedDateHoliday
occurs.
A string giving the weekday on which the
NthWeekdayInMonthHoliday
occurs.
An integer specifying the week of the month on which
the NthWeekdayInMonthHoliday
occurs. If which.week <=
0
then the holiday is assumed to occur on the last
day.of.week
in month
.
If NULL
then all named holidays are returned. If
except is a character vector containing partial matches to holiday
names, the matched names will be omitted from the returned list.
NamedHolidays
returns a character vector with the names of the
recognized holiday.
The other functions return state.specification
, after adding the
requested state components.
AddNthWeekdayInMonthHoliday
, AddLastWeekdayInMonthHoliday
,
and AddFixedDateHoliday
can each add one holiday at a time.
AddNamedHolidays
will add several holidays at once, if
named.holidays
is a vector.
Harvey (1990), "Forecasting, structural time series, and the Kalman filter", Cambridge University Press.
Durbin and Koopman (2001), "Time series analysis by state space methods", Oxford University Press.
# NOT RUN {
## TODO(stevescott): add examples
# }
Run the code above in your browser using DataLab