Kkronm: The product of Kronecker Product of some Arrays

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/code.R

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:

Usage

1
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 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.

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

 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)

DCCA documentation built on Jan. 1, 2020, 5:06 p.m.

Related to Kkronm in DCCA...