padMatrix: Increase data length to the closest power of 2.

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/padMatrix.R

Description

To use the WiSE bootstrap methodology in this package, data must be of length T=2^J for some positive integer, J. This function increases the length of data to achieve the particular length requirement. Generally, this function is useful for data pre-processing.

Usage

1
2
padMatrix(X, by.row = TRUE, type = "reflect", pad.direction = "both", 
          replaceLinearTrend = FALSE)

Arguments

X

a matrix of data. This must be numeric and non-missing.

by.row

logical indicator of observation location. If by.row=TRUE, the matrix contains observations in the rows and each column represents a different data series (padding data by column). If by.row=FALSE, the matrix contains observations in the columns and each row represents a different data series (padding data by row).

type

how to increase the data length. Allowed values are "reflect", "periodic", or "mean". The "reflect" option repeats values proceeding the end/beginning of the series (ex: 12345 --> 12345432). The "periodic" option repeats the series in order (ex: 12345 --> 12345123). The "mean" option repeats the series mean (ex: 12345 --> 12345333 ).

pad.direction

where to add the data padding. Allowed values are "both", "front", or "rear". The "both" option pads data on both sides of the series (ex: 12345 --> 31234533). The "front" option pads data on the beginning of the series (ex: 12345 --> 33312345). The "rear" option pads data on the end of the series (ex: 12345 --> 12345333).

replaceLinearTrend

logical. If TRUE, the estimated linear trend is replaced in the returned data. If FALSE, the estimated trend is not replaced in the returned data. See Details for more information.

Details

If the data supplied is already a power of 2, this function will just return the original or de-trended data.

If the data supplied is of length, t, the padded data returned will be of length T=2^{ceiling(log(t, base=2))}.

The data length T=2^J for a positive integer, J, requirement is associated with the discrete wavelet transform. Although methodology exists in the wavelet literature which allows for data series of any length, this methodology does not align with the theory behind WiSE bootstrap.

The replaceLinearTrend option allows the user to control whether linear trend appears in the padded data. The linear trend (by data index) is estimated using least squares for each data series. This trend is removed before padding the data. The estimated trend may or may not be replaced to the padded data. The linear trend consists of the data intercept and slope (by index).

Value

xPad

a matrix of padded data. This matrix contains the same number of supplied data series, but the data series will be of length T instead of t (see Details).

origSeriesIndex

a vector of 2 indices. These indicate where the original data is in the padded series. Note, the xPad will not exactly match the original data between these indices, since the linear trend has been estimated (and possibly replaced).

linearParam

a matrix with 2 rows. The first row is the least squares estimated intercept and the second is the least squares estimated slope (by index) from the data originally supplied. The columns correspond to the individual data series, in order of X.

by.row

same as supplied to the function.

Author(s)

Megan Heyman

See Also

padVector, wavethresh-package

Examples

1
2
3
4
5
someData <- matrix(seq(1,5^2)+rnorm(25), nrow=7) 

padMatrix(someData)
padMatrix(someData, type="mean", pad.direction="rear")
padMatrix(someData, type="periodic", pad.direction="front")

WiSEBoot documentation built on May 30, 2017, 3:32 a.m.