| Kkronm {DCCA} | R Documentation |
The product of Kronecker Product of some Arrays
Description
This is an auxiliary function and requires some context to be used adequadely. It computes equation (19) in Prass and Pumi (2019), returning a square matrix defined by
K* = (Jm \%x\% J*)'(Q \%x\% Q)(Jm \%x\% J*)
where:
-
Jis an(m+1)*(h+1) - m*h*sby(m+1)*(h+1) - m*h*slower triangular matrix with all non-zero entries equal to one, withs = 1if overlap = TRUE ands = 0, otherwise; -
Jmcorresponds to the firstm+1rows and columns ofJ; -
J*corresponds to the lastm+1rows ofJ; -
Q = I-P, wherePis them+1bym+1projection matrix into the subspace generated by degreenu+1polynomials.
Usage
Kkronm(m = 3, nu = 0, h = 0, overlap = TRUE, K = NULL)
Arguments
m |
a positive integer indicating the size of the window for the polinomial fit. |
nu |
a non-negative integer denoting the degree of the polinomial fit applied on the integrated series. |
h |
an integer indicating the lag. |
overlap |
logical: if true (the default), overlapping boxes are used for calculations. Otherwise, non-overlapping boxes are applied. |
K |
optional: the matrix defined by |
Value
an (m+1)[(m+1)*(h+1) - m*h*s] by (m+1)[(m+1)*(h+1) - m*h*s] matrix, where s = 1 if overlap = TRUE and s = 0, otherwise. This matrix corresponds to equation (19) in Prass and Pumi (2019).
Author(s)
Taiane Schaedler Prass
References
Prass, T.S. and Pumi, G. (2019). On the behavior of the DFA and DCCA in trend-stationary processes <arXiv:1910.10589>.
See Also
Jn which creates the matrix J, Qm which creates Q and Km which creates K.
Examples
m = 3
h = 1
J = Jn(n = m+1+h)
Q = Qm(m = m, nu = 0)
# using K
K = Km(J = J[1:(m+1),1:(m+1)], Q = Q)
Kkron0 = Kkronm(K = K, h = h)
# using m and nu
Kkron = Kkronm(m = m, nu = 0, h = h)
# using kronecker product from R
K = Km(J = J[1:(m+1),1:(m+1)], Q = Q)
Kh = rbind(matrix(0, nrow = h, ncol = m+1+h),
cbind(matrix(0, nrow = m+1, ncol = h), K))
KkronR = K %x% Kh
# using the definition K* = (Jm %x% J)'(Q %x% Q)(Jm %x% J)
J_m = J[1:(m+1),1:(m+1)]
J_h = J[(h+1):(m+1+h),1:(m+1+h)]
KkronD = t(J_m %x% J_h)%*%(Q %x% Q)%*%(J_m %x% J_h)
# comparing the results
sum(abs(Kkron0 - Kkron))
sum(abs(Kkron0 - KkronR))
sum(abs(Kkron0 - KkronD)) # difference due to rounding error
## Not run:
# Function Kkronm is computationaly faster than a pure implementation in R:
m = 100
h = 1
J = Jn(n = m+1)
Q = Qm(m = m, nu = 0)
# using Kkronm
t1 = proc.time()
Kkron = Kkronm(m = m, nu = 0, h = 1)
t2 = proc.time()
# elapsed time:
t2-t1
# Pure R implementation:
K = Km(J = J, Q = Q)
Kh = rbind(matrix(0, nrow = h, ncol = m+1+h),
cbind(matrix(0, nrow = m+1, ncol = h), K))
t3 = proc.time()
KkronR = K %x% Kh
t4 = proc.time()
# elapsed time
t4-t3
## End(Not run)