| dacor_large | R Documentation |
Computes lag-lag distance autocorrelation for the rows of x. If
block_size = NULL, the standard full pairwise-distance computation is
used. If block_size is a positive integer, a blockwise algorithm is
used that avoids allocating the full (n-lag) \times (n-lag) distance
matrices.
dacor_large(x, lag = 1L, block_size = NULL)
x |
A numeric vector or numeric matrix. Rows are observations ordered in time. |
lag |
A positive integer smaller than |
block_size |
Either |
Vectors are treated as one-column matrices.
Distance autocorrelation is computed as the distance correlation between
x[1:(n-lag), ] and x[(1+lag):n, ].
If block_size = NULL, the required pairwise distances are computed
using the standard full computation.
If block_size is a positive integer, the effective sample of size
n - lag is partitioned into consecutive blocks of size at most
block_size, and distances are accumulated block by block. Only one
block pair is stored at a time, which can substantially reduce memory usage.
The block size does not need to divide n - lag. If n - lag is
not a multiple of block_size, the final block is simply smaller.
The blockwise algorithm mainly reduces memory usage; the computational
complexity remains of order O((n-lag)^2).
A numeric scalar giving the distance autocorrelation at lag
lag.
Székely, G. J., Rizzo, M. L., and Bakirov, N. K. (2007). Measuring and testing dependence by correlation of distances. Annals of Statistics, 35(6), 2769–2794. doi:10.1214/009053607000000505.
Székely, G. J. and Rizzo, M. L. (2009). Brownian distance covariance. Annals of Applied Statistics, 3(4), 1236–1265. doi:10.1214/09-AOAS312.
Fokianos, K. and Pitsillou, M. (2017). Consistent testing for pairwise dependence in time series. Technometrics, 59(2), 262–270. doi:10.1080/00401706.2016.1156024.
set.seed(1)
n <- 100
x <- matrix(rnorm(n * 2), n, 2)
r1 <- dacor_large(x, lag = 1L)
r2 <- dacor_large(x, lag = 1L, block_size = 32L)
r1
r2
all.equal(r1, r2, tolerance = 1e-10)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.