mv_impute {mvLSWimpute} | R Documentation |
Function to apply the mvLSWimpute method and impute missing values in a multivariate locally stationary time series
Description
This function applies the mvLSWimpute method to impute missing values in a multivariate locally stationary time series. The imputation can be based on forecasts only or use information from both a forecasting and backcasting step.
Usage
mv_impute(data, p = 2, type = "forward", index = NULL)
Arguments
data |
Input multivariate time series, matrix of dimension TxP where P is the number of channels and T is the length of the series. |
p |
The number of terms to include in the clipped predictor when carrying out one step ahead forecasting/backcasting. |
type |
The type of imputation to carry out, either |
index |
The set of time indices containing missing values, this is |
Value
Returns a list containing the following elements:
ImputedData |
Matrix containing the imputed time series. |
missing.index |
Vector containing the set of time indices that have missing values. |
Note
As with other time series imputation methods, mv_impute
requires some data values at the start of the series. In this case, we need 5 time points.
Author(s)
Rebecca Wilson
References
Wilson, R. E., Eckley, I. A., Nunes, M. A. and Park, T. (2021) A wavelet-based approach for imputation in nonstationary multivariate time series. _Statistics and Computing_ *31* Article 18, doi:10.1007/s11222-021-09998-2.
Examples
set.seed(1)
X <- matrix(rnorm(2 * 2^8), ncol = 2)
X[1:2^7, 2] <- 3 * (X[1:2^7, 2] + 0.95 * X[1:2^7, 1])
X[-(1:2^7), 2] <- X[-(1:2^7), 2] - 0.95 * X[-(1:2^7), 1]
X[-(1:2^7), 1] <- X[-(1:2^7), 1] * 4
X <- as.ts(X)
# create some fake missing data, taking care not to have missingness hear the start of the series
missing.index = sort(sample(10:2^8, 30))
X[missing.index, ] <- NA
newdata = mv_impute(X)