Combine mutliple objects of persephone objects into a new hierachical persephone object. On the resulting time series the user can perform direct and indirect seasonal adjustments.

Super classes

persephone::persephone -> persephone::multipleTimeSeries -> hierarchicalTimeSeries

Public fields

components

the sub series of the hierarchical time series

weights

the weights used for aggregating components

indirect

wether to use direct or indirect adjustement

Active bindings

params

of all components and the aggregated series

paramsDirect

params of the aggregated series

adjustedIndirect

results from the indirect adjustment where all components are adjusted and then aggregated

adjusted

results from the seasonal adjustment

forecasts

get forecasts

forecastsIndirect

get forecasts according to indirect adjustments

Methods

Inherited methods


Method new()

create a new hierarchical time series

Usage

hierarchicalTimeSeries$new(
  ...,
  method = c("tramoseats", "x13"),
  userdefined = NULL,
  spec = NULL,
  list = NULL,
  weights = NULL
)

Arguments

...

one or more objects which are either of class persephone or can be coerced to persephone objects with asPersephone. If more than one element is supplied, the underlying time series must have the same time instances. All elements supplied in ... must be named.

method

specifies the method to be used for the direct adjustment of the aggregate series. tramoseats or x13

userdefined

passed as the userdefined argument to tramoseats() or x13()

spec

a model specification returned by x13_spec() or tramoseats_spec()

list

a list of persephone objects as alternative input to .... This argument can also handle mts objects

weights

either a vector if the same weight is used for all time points or a list of ts objects or a mts object if the weight varies for different time points. They must have the same length as the number of components.


Method run()

run the model

Usage

hierarchicalTimeSeries$run(verbose = FALSE)

Arguments

verbose

if FALSE (the default), the results of the run will be returned invisibly

Examples

perX13(AirPassengers)$run()


Method print()

print a hierarchical timeseries to screen

Usage

hierarchicalTimeSeries$print()


Method setOptions()

sets options for all entries of the dependency tree recursively (if recursive = TRUE). See vignette("persephone-hierarchical") for more details.

Usage

hierarchicalTimeSeries$setOptions(
  userdefined = NA,
  spec = NA,
  recursive = TRUE,
  component = ""
)

Arguments

userdefined

additional outputs to generate while running. See x13() and tramoseats().

spec

specifications generated by x13_spec() or tramoseats_spec()

recursive

apply this setting to all subseries as well?

component

which component to modify.


Method iterate()

iterate over all components

Usage

hierarchicalTimeSeries$iterate(
  fun,
  asTable = FALSE,
  component = "",
  unnest = FALSE
)

Arguments

fun

a function that takes a persephone object as a parameter

asTable

if true, the return value of this method will be coerced to a data.frame

component

the id of the component

unnest

if asTable = FALSE, converts the return value from a nested list into a flat list

Details

this functin is similar to lapply() in the sense that it can be used to apply a function to several persephone objects simultaniusely


Method getComponent()

extract a component series

Usage

hierarchicalTimeSeries$getComponent(componentId)

Arguments

componentId

the id of a component


Method updateParams()

change all or some parameters of components

Usage

hierarchicalTimeSeries$updateParams(component = NULL, ...)

Arguments

component

character vector with names of the components for which the parameters should be changed. If NULL (default) the parameters of all components will be changed

...

named arguments to be changed

Details

this functions provides the possibility to update parameters of one or more persephone single objects


Method fixModel()

fix the arima model(s)

Usage

hierarchicalTimeSeries$fixModel(component = NULL, verbose = FALSE)

Arguments

component

character vector with names of the components for which the parameters should be changed. If NULL (default) the parameters of all components will be changed

verbose

if TRUE the changed parameters will be reported


Method fixOutlier()

fix the automatically detected outliers and the span to find new automatically detected outliers

Usage

hierarchicalTimeSeries$fixOutlier(
  component = NULL,
  timespan = 12,
  verbose = FALSE
)

Arguments

component

character vector with names of the components for which the parameters should be changed. If NULL (default) the parameters of all components will be changed

timespan

number of months from the end of the time series where outliers are not fixed

verbose

if TRUE the changed parameters will be reported


Method generateQrTable()

Generate a table for the eurostat quality report

Usage

hierarchicalTimeSeries$generateQrTable(component = "")

Arguments

component

(optional) a sub-component to create the report for


Method clone()

The objects of this class are cloneable with this method.

Usage

hierarchicalTimeSeries$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

if (FALSE) {
objX13 <- perX13(AirPassengers, "RSA3")

ht <- perHts(a = objX13, b = objX13, method = "x13", spec = "RSA1")

ht$updateParams(easter.enabled = TRUE)

ht$updateParams(component = "a", usrdef.outliersEnabled = TRUE,
                     usrdef.outliersType = c("AO","LS","LS"),
                     usrdef.outliersDate=c("1950-01-01","1955-04-01","1959-10-01"))
ht$run()
ht$adjustedDirect
ht$adjustedIndirect

ht2 <- perHts(a = ht, b = objX13)
ht2$run()
ht2$adjustedDirect
ht2$adjustedIndirect
}

## ------------------------------------------------
## Method `hierarchicalTimeSeries$run`
## ------------------------------------------------

perX13(AirPassengers)$run()