Description Usage Arguments Value Author(s) References See Also Examples
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:
J is an (m+1)*(h+1) - m*h*s by (m+1)*(h+1) - m*h*s lower triangular matrix with all non-zero entries equal to one, with s = 1 if overlap = TRUE and s = 0, otherwise;
Jm corresponds to the first m+1 rows and columns of J;
J* corresponds to the last m+1 rows of J;
Q = I-P, where P is the m+1 by m+1 projection matrix into the subspace generated by degree nu+1 polynomials.
1 |
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 K = J'QJ. This is used to calculate K* = (Jm \%x\% J*)'(Q \%x\% Q)(Jm \%x\% J*). For details see (19) in Prass and Pumi (2019). If this matrix is provided mu is ignored. |
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).
Taiane Schaedler Prass
Prass, T.S. and Pumi, G. (2019). On the behavior of the DFA and DCCA in trend-stationary processes <arXiv:1910.10589>.
Jn
which creates the matrix J, Qm
which creates Q and Km
which creates K.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.