calc_startpoints: Calculate a vector of start points by lagging (shifting) a...

View source: R/RcppExports.R

calc_startpointsR Documentation

Calculate a vector of start points by lagging (shifting) a vector of end points.

Description

Calculate a vector of start points by lagging (shifting) a vector of end points.

Usage

calc_startpoints(endd, lookb)

Arguments

endd

An integer vector of end points.

lookb

The length of the look-back interval, equal to the lag (shift) applied to the end points.

Details

The start points are equal to the values of the vector endd lagged (shifted) by an amount equal to lookb. In addition, an extra value of 1 is added to them, to avoid data overlaps. The lag operation requires appending a beginning warmup interval containing zeros, so that the vector of start points has the same length as the endd.

For example, consider the end points for a vector of length 25 divided into equal intervals of length 5: 4, 9, 14, 19, 24. (In C++ the vector indexing starts at 0 not 1, so it's shifted by -1.) Then the start points for lookb = 2 are equal to: 0, 0, 5, 10, 15. The differences between the end points minus the corresponding start points are equal to 9, except for the warmup interval.

Value

An integer vector with the same number of elements as the vector endd.

Examples

# Calculate end points
endd <- HighFreq::calc_endpoints(length=55, step=5)
# Calculate start points corresponding to the end points
startp <- HighFreq::calc_startpoints(endd, lookb=5)


algoquant/HighFreq documentation built on Feb. 9, 2024, 8:15 p.m.