Learn R Programming

hicp (version 1.1.0)

linking: Linking-in new index series

Description

The function link() links a new index series (x.new) to an existing one (x) using the overlap periods in t.overlap. In the resulting linked index series, the new index series starts after the existing one.

The function lsf() computes the level-shift factors for linking via the overlap periods in t.overlap in comparison to the standard one-month overlap method using December of year t-1. The level-shift factors can then be used to shift the index level of a HICP index series.

Usage

link(x, x.new, t, t.overlap=NULL, settings=list())

lsf(x, x.new, t, t.overlap=NULL, settings=list())

Value

The function link() returns a numeric vector or a matrix of the same length as t, while lsf() provides a named numeric vector of the same length as t.overlap.

Author

Sebastian Weinand

Arguments

x, x.new

numeric vector of index values. NA-values in the vectors indicate when the index series discontinues (for x) or starts (for x.new).

t

date vector of monthly (i.e., one observation per month), quarterly or yearly frequency in format YYYY-MM-DD.

t.overlap

character specifying the overlap period either in format YYYY for a calendar year or YYYY-MM for a specific month or quarter. Multiple periods can be provided. If NULL, all intersecting periods in x and x.new are used.

settings

list of control settings to be used. The following settings are supported:

  • chatty : logical indicating if package-specific warnings and info messages should be printed or not. The default is getOption("hicp.chatty").

  • freq : character specifying the frequency of t. Allowed values are month, quarter, year, and auto (the default). For auto, the frequency is internally derived from t.

  • na.rm : logical indicating if averages for calendar years should also be computed when there are NAs and less than 12 months (or 4 quarters) present (for na.rm=TRUE).

See Also

chain

Examples

Run this code
# input data:
set.seed(1)
t <- seq.Date(from=as.Date("2015-01-01"), to=as.Date("2024-05-01"), by="1 month")
x.new <- rnorm(n=length(t), mean=100, sd=5)
x.new <- rebase(x=x.new, t=t, t.ref="2019-12")
x.old <- x.new + rnorm(n=length(x.new), sd=5)
x.old <- rebase(x=x.old, t=t, t.ref="2015")
x.old[t>as.Date("2021-12-01")] <- NA # current index discontinues in 2021
x.new[tas.Date("2021-12-01"),
                    yes=x.new.chained*lsf(x=x.old, x.new=x.new, t=t, t.overlap="2020"),
                    no=x.new.chained)

# compare:
all.equal(x.new.adj, link(x=x.old, x.new=x.new, t=t, t.overlap="2020"))

Run the code above in your browser using DataLab