Computes a subset of pairwise differences between observations by forming successive differences up to a fixed lag.
mdiff(X, m = 20)A numeric matrix with \(n m\) rows and the same number of columns as
X, containing the successive difference vectors.
A numeric data matrix with observations in rows and variables in columns.
A positive integer specifying the number of successive differences to be computed for each observation.
Let \(X\) be a data matrix with \(n\) rows, denoted by \(x_1, \dots, x_n\). The function computes a matrix of successive differences consisting of the vectors \(x_i - x_{i+j}\), for \(j = 1, \dots, m\).
To ensure that each observation contributes exactly \(m\) differences, the first \(m\) observations are appended to the end of the data matrix before computing the differences. As a result, the output contains \(n m\) difference vectors.
The resulting set of differences forms a subset of all possible pairwise differences and provides a computationally cheaper alternative to using all \(n(n-1)/2\) differences. Such constructions are useful, for example, in approximations of symmetrized scatter estimators.
Dumbgen, L. and Nordhausen, K. (2024). Approximating symmetrized estimators of scatter via balanced incomplete U-statistics. Annals of the Institute of Statistical Mathematics, 76, 185--207. <doi:10.1007/s10463-023-00879-1>.
X <- matrix(1:12, ncol=2)
mdiff(X, m=3)
Run the code above in your browser using DataLab