Description Usage Arguments Value Author(s) References Examples

Calculates the detrended variance based on a given time series.

1 |

`y` |
vector corresponding to the time series data. |

`m` |
an integer or integer valued vector indicating the size (or sizes) of the window for the polinomial fit. |

`nu` |
a non-negative integer denoting the degree of the polinomial fit applied on the integrated series. |

`overlap` |
logical: if true (the default), uses overlapping windows. Otherwise, non-overlapping boxes are applied. |

A vector of size *length(m)* containing the detrended variance considering windows of size *m+1*, for each *m* supplied.

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

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 57 58 59 60 61 62 63 64 65 66 | ```
# Simple usage
y = rnorm(100)
F2.dfa = F2dfa(y, m = 3, nu = 0, overlap = TRUE)
F2.dfa
vF2.dfa = F2dfa(y, m = 3:5, nu = 0, overlap = TRUE)
vF2.dfa
###################################################
# AR(1) example showing how the DFA varies with phi
phi = (1:8)/10
n = 300
z = matrix(nrow = n, ncol = length(phi))
for(i in 1:length(phi)){
z[,i] = arima.sim(model = list(ar = phi[i]), n)
}
ms = 3:50
F2.dfa = matrix(ncol = length(phi), nrow = length(ms))
for(j in 1:length(phi)){
F2.dfa[,j] = F2dfa(z[,j], m = ms , nu = 0, overlap = TRUE)
}
cr = rainbow(length(phi))
plot(ms, F2.dfa[,1], type = "o", xlab = "m", col = cr[1],
ylim = c(0,max(F2.dfa)), ylab = "F2.dfa")
for(j in 2:length(phi)){
points(ms, F2.dfa[,j], type = "o", col = cr[j])
}
legend("topleft", lty = 1, legend = phi, col = cr, bty = "n", title = expression(phi), pch=1)
##############################################################################
# An MA(2) example showcasing why overlapping windows are usually advantageous
n = 300
ms = 3:50
theta = c(0.4,0.5)
# Calculating the expected value of the DFA in this scenario
m_max = max(ms)
vtheta = c(c(1,theta, rep(0, m_max - length(theta))))
G = matrix(0, ncol = m_max+1, nrow = m_max+1)
for(t in 1:(m_max+1)){
for(h in 0:(m_max+1-t)){
G[t,t+h] = sum(vtheta[1:(length(vtheta)-h)]*vtheta[(1+h):length(vtheta)])
G[t+h,t] = G[t,t+h]
}
}
EF2.dfa = EF2dfa(m = ms, nu = 0, G = G)
z = arima.sim(model = list(ma = theta), n)
ms = 3:50
OF2.dfa = F2dfa(z, m = ms, nu = 0, overlap = TRUE)
NOF2.dfa = F2dfa(z, m = ms, nu = 0, overlap = FALSE)
plot(ms, OF2.dfa, type = "o", xlab = "m", col = "blue",
ylim = c(0,max(OF2.dfa,NOF2.dfa,EF2.dfa)), ylab = "F2.dfa")
points(ms, NOF2.dfa, type = "o", col = "darkgreen")
points(ms, EF2.dfa, type = "o", col = "red")
legend("bottomright", legend = c("overlapping","non-overlapping","expected"),
col = c("blue", "darkgreen","red"), lty= 1, bty = "n", pch=1)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.