Package 'DFA'

Title: Detrended Fluctuation Analysis
Description: Contains the Detrended Fluctuation Analysis (DFA), Detrended Cross-Correlation Analysis (DCCA), Detrended Cross-Correlation Coefficient (rhoDCCA), Delta Amplitude Detrended Cross-Correlation Coefficient (DeltarhoDCCA), log amplitude Detrended Fluctuation Analysis (DeltalogDFA), two DFA automatic methods for identification of crossover points and a Deltalog automatic method for identification of reference channels.
Authors: Victor Barreto Mesquita[aut,cre],Paulo Canas Rodrigues[ctb], Florencio Mendes Oliveira Filho[ctb]
Maintainer: Victor Barreto Mesquita <[email protected]>
License: GPL-3
Version: 0.9.0
Built: 2025-03-09 03:24:53 UTC
Source: https://github.com/victormesquita40/dfa

Help Index


Area Under the Curve

Description

Applies the Area Under the Curve on the log-log curve.

Usage

AUC(x,data)

Arguments

x

Vector of the decimal logarithm of the boxes sizes.

data

A data frame of different decimal logarithm of the DFA calculated in each boxe.

Details

Compute the Area Under the Curve to a data frame. The method returns the curve with higher AUC.

Value

position

Position of the DFA curve with higher Area Under the Curve (AUC).

Area

Respective Area Under the Curve (AUC) computed by trapezoidal rule for the channel with higher AUC.

Note

All of log-log curve contained in the data frame must have the same sample size.

Author(s)

Victor Barreto Mesquita

References

https://www.khanacademy.org/math/ap-calculus-ab/ab-integration-new/ab-6-2/a/understanding-the-trapezoid-rule

https://en.wikipedia.org/wiki/Trapezoidal_rule

Examples

# Example with a data frame with different DFA exponents ranging from short 0.1 to long 0.9.
# The functions returns the channel with higher AUC and its respective area.

library(DFA)
#library(latex2exp) # it is necessary for legend of the plot function

data("lrcorrelation")

#plot(lrcorrelation$`log10(boxes)`,lrcorrelation$`log10(DFA(alpha = 0.9))`
#     ,xlab=TeX("$log_{10}(n)$"),ylab=TeX("$log_{10}F_{DFA}(n)$"),col="black"
#     ,pch=19, ylim= c(-0.8,1.2))
#lines(lrcorrelation$`log10(boxes)`,lrcorrelation$`log10(DFA(alpha = 0.8))`,type="p"
#      ,col="blue", pch=19)
#lines(lrcorrelation$`log10(boxes)`,lrcorrelation$`log10(DFA(alpha = 0.7))`,type="p"
#      ,col="red", pch=19)
#lines(lrcorrelation$`log10(boxes)`,lrcorrelation$`log10(DFA(alpha = 0.6))`,type="p"
#      ,col="green", pch=19)
#lines(lrcorrelation$`log10(boxes)`,lrcorrelation$`log10(DFA(alpha = 0.5))`,type="p"
#      ,col="brown", pch=19)
#lines(lrcorrelation$`log10(boxes)`,lrcorrelation$`log10(DFA(alpha = 0.4))`,type="p"
#      ,col="yellow", pch=19)
#lines(lrcorrelation$`log10(boxes)`,lrcorrelation$`log10(DFA(alpha = 0.3))`,type="p"
#      ,col="orange", pch=19)
#lines(lrcorrelation$`log10(boxes)`,lrcorrelation$`log10(DFA(alpha = 0.2))`,type="p"
#      ,col="pink", pch=19)
#lines(lrcorrelation$`log10(boxes)`,lrcorrelation$`log10(DFA(alpha = 0.1))`,type="p"
#      ,col="magenta", pch=19)

#legend("bottom", legend=c(TeX("$\alpha_{DFA} = 0.9$"),TeX("$\alpha_{DFA} = 0.8$")
#                          ,TeX("$\alpha_{DFA} = 0.7$"),TeX("$\alpha_{DFA} = 0.6$")
#                          ,TeX("$\alpha_{DFA} = 0.5$"),TeX("$\alpha_{DFA} = 0.4$")
#                          ,TeX("$\alpha_{DFA} = 0.3$"),TeX("$\alpha_{DFA} = 0.2$")
#                          ,TeX("$\alpha_{DFA} = 0.1$"))
#       , col=c("black","blue","red","green","brown","yellow","orange","pink","magenta")
#       , pch=c(19,19,19,19,19,19,19,19,19)
#       , cex = 0.55
#       , ncol = 5
#)

x = lrcorrelation$`log10(boxes)`

data = lrcorrelation

AUC(x,data)

Detrended Cross-Correlation Analysis (DCCA)

Description

Applies the Detrended Cross-Correlation Analysis (DCCA) to nonstationary time series.

Usage

DCCA(file,file2,scale = 2^(1/8),box_size = 4,m=1)

Arguments

file

Univariate time series (must be a vector or data frame)

file2

Univariate time series (must be a vector or data frame)

scale

Specifies the ratio between successive box sizes (by default scale = 2^(1/8))

box_size

Vector of box sizes (must be used in conjunction with scale = "F")

m

An integer of the polynomial order for the detrending (by default m=1).

Details

The Detrended Cross-Correlation Analysis method (DCCA) can be computed in a geometric scale or for different choices of boxes sizes.

Value

boxe

Size nn of the overlapping boxes.

DFA1

DFA of the first time series (file).

DFA2

DFA of the second time series (file2).

DCCA

Detrended Cross-Correlation function.

Note

The time series file and file2 must have the same sample size.

Author(s)

Victor Barreto Mesquita

References

N. Xu, P. Shang, S. Kamae Modeling traffic flow correlation using DFA and DCCA Nonlinear Dynam., 61 (2010), pp. 207-216

B. Podobnik, D. Horvatic, A. Petersen, H.E. Stanley Cross-correlations between volume change and price change PNAS, 106 (52) (2009), pp. 22079-22084

R. Ursilean, A.-M. Lazar Detrended cross-correlation analysis of biometric signals used in a new authentication method Electr. Electron. Eng., 1 (2009), pp. 55-58

Examples

#The following examples using the database of financial time series
#collected during the United States bear market of 2007-2009.

library(DFA)
data("NYA2008")
data("IXIC2008")
file = NYA2008
file2= IXIC2008

DCCA(file,file2,scale = 2^(1/8),box_size = c(4,8,16),m=1)


# Example with different polynomial fit order.

library(DFA)
data("NYA2008")
data("LSE.L2008")
file = NYA2008
file2= LSE.L2008

DCCA(file,file2,scale = 2^(1/8),box_size = c(4,8,16),m=2)


# Example using different choice of overlapping boxes sizes.

library(DFA)
data("NYA2008")
data("IXIC2008")
file = NYA2008
file2= IXIC2008

DCCA(file,file2,scale = "F",box_size = c(4,8,16),m=1)

log-amplitude Detrended Fluctuation Analysis (DeltaDFA)

Description

Applies the log-amplitude Detrended Fluctuation Analysis (DFA) to nonstationary time series.

Usage

DeltaDFA(file,file2,scale = 2^(1/8),box_size = 4,m=1)

Arguments

file

Univariate time series (must be a vector or data frame)

file2

Univariate time series (must be a vector or data frame)

scale

Specifies the ratio between successive box sizes (by default scale = 2^(1/8))

box_size

Vector of box sizes (must be used in conjunction with scale = "F")

m

An integer of the polynomial order for the detrending (by default m=1).

Details

The DFA log-amplitude fluctuation can be computed in a geometric scale or for different choices of boxes sizes.

Value

boxe

Size nn of the overlapping boxes.

DeltaDFA

log-amplitude Detrended Fluctuation function defined as the difference between the DFA decimal logarithmic of the first time series (file) and the DFA decimal logarithmic of the second time series (file2)

Note

The time series file and file2 must have the same sample size.

Author(s)

Victor Barreto Mesquita

References

G. F. Zebende, F. M. Oliveira Filho, J. A. L. Cruz, Auto-correlationin the motor/imaginary human eeg signals: A vision about the fdfafluctuations, PloS one 12 (9) (2017).

F. Oliveira Filho, J. L. Cruz, G. Zebende, Analysis of the eeg bio-signalsduring the reading task by dfa method, Physica A: Statistical Mechanicsand its Applications 525 (2019) 664-671.

S. R. Hirekhan, R. R. Manthalkar, The detrended fluctuation and cross-correlation analysis of eeg signals, International Journal of IntelligentSystems Design and Computing 2 (2) (2018) .

Examples

#The following examples using the database of financial time series
#collected during the United States bear market of 2007-2009.

library(DFA)
data("NYA2008")
data("IXIC2008")
file = NYA2008
file2= IXIC2008

DeltaDFA(file,file2,scale = 2^(1/8),box_size = c(4,8,16),m=1)


# Example with different polynomial fit order.

library(DFA)
data("NYA2008")
data("LSE.L2008")
file = NYA2008
file2= LSE.L2008

DeltaDFA(file,file2,scale = 2^(1/8),box_size = c(4,8,16),m=2)


# Example using differente choice of overlapping boxes sizes.

library(DFA)
data("NYA2008")
data("IXIC2008")
file = NYA2008
file2= IXIC2008

DeltaDFA(file,file2,scale = "F",box_size = c(4,8,16),m=1)

Delta Amplitude Detrended Cross-Correlation Coefficient (DeltarhoDCCA)

Description

Applies the Detrended Cross-Correlation Coefficient Difference (Deltarho) to nonstationary time series.

Usage

Deltarho(file,file2,file3,file4,scale = 2^(1/8),box_size = 4,m=1)

Arguments

file

Univariate time series (must be a vector or data frame)

file2

Univariate time series (must be a vector or data frame)

file3

Univariate time series (must be a vector or data frame)

file4

Univariate time series (must be a vector or data frame)

scale

Specifies the ratio between successive box sizes (by default scale = 2^(1/8))

box_size

Vector of box sizes (must be used in conjunction with scale = "F")

m

An integer of the polynomial order for the detrending (by default m=1).

Details

The Deltarho can be computed in a geometric scale or for different choices of boxes sizes.

Value

boxe

Size nn of the overlapping boxes.

DFA1

DFA of the first time series (file).

DFA2

DFA of the second time series (file2).

DFA3

DFA of the third time series (file3).

DFA4

DFA of the fourth time series (file4).

DCCA

Detrended Cross-Correlation function between the first time series (file) and the second time series (file2).

DCCA2

Detrended Cross-Correlation function between the third time series (file3) and the fourth time series (file4).

rhoDCCA

Detrended Cross-Correlation Coefficient function, defined as the ratio between the DCCA and two DFA (DFA1,DFA2).

rhoDCCA2

Detrended Cross-Correlation Coefficient function, defined as the ratio between the DCCA2 and two DFA (DFA3,DFA4).

Note

The time series file,file2,file3 and file4 must have the same sample size.

Author(s)

Victor Barreto Mesquita

References

SILVA, Marcus Fernandes da et al. Quantifying cross-correlation between ibovespa and brazilian blue-chips: The dcca approach. Physica A: Statistical Mechanics and its Applications, v. 424,2015.

Examples

#The following examples using the database of financial time series
#collected during the United States bear market of 2007-2009.

library(DFA)
data("NYA2008")
data("IXIC2008")
data("LSE.L2008")
data("SSEC2008")

file = NYA2008
file2= IXIC2008
file3 = LSE.L2008
file4 = SSEC2008

Deltarho(file,file2,file3,file4,scale = 2^(1/8),box_size = c(4,8,16),m=1)


# Example with different polynomial fit order.

library(DFA)
data("NYA2008")
data("IXIC2008")
data("LSE.L2008")
data("SSEC2008")

file = NYA2008
file2 = LSE.L2008
file3= IXIC2008
file4 = SSEC2008

Deltarho(file,file2,file3,file4,scale = 2^(1/8),box_size = c(4,8,16),m=2)



# Example using different choice of overlapping boxes sizes.

library(DFA)
data("NYA2008")
data("IXIC2008")
data("LSE.L2008")
data("SSEC2008")

file = NYA2008
file2= IXIC2008
file3 = LSE.L2008
file4 = SSEC2008

Deltarho(file,file2,file3,file4,scale = "F",box_size = c(4,8,16),m=1)

Detrended Fluctuation Analysis (DFA)

Description

Applies the Detrended Fluctuation Analysis (DFA) to nonstationary time series.

Usage

DFA(file,scale = 2^(1/8),box_size = 4,m=1)

Arguments

file

Univariate time series (must be a vector or data frame)

scale

Specifies the ratio between successive box sizes (by default scale = 2^(1/8))

box_size

Vector of box sizes (must be used in conjunction with scale = "F")

m

An integer of the polynomial order for the detrending (by default m=1).

Details

The DFA fluctuation can be computed in a geometric scale or for different choices of boxes sizes.

Value

boxe

Size nn of the overlapping boxes.

DFA

Detrended Fluctuation function.

Note

The time series file and file2 must have the same sample size.

Author(s)

Victor Barreto Mesquita

References

C.-K. Peng, S.V. Buldyrev, S. Havlin, M. Simons, H.E. Stanley, A.L. Goldberger Phys. Rev. E, 49 (1994), p. 1685

H.E. Stanley, L.A.N. Amaral, A.L. Goldberger, S. Havlin, P.Ch. Ivanov, C.-K. Peng Physica A, 270 (1999), p. 309

P.C. Ivanov, A. Bunde, L.A.N. Amaral, S. Havlin, J. Fritsch-Yelle, R.M. Baevsky, H.E. Stanley, A.L. Goldberger Europhys. Lett., 48 (1999), p. 594

P. Talkner, R.O. Weber Phys. Rev. E, 62 (2000), p. 150

M. Ausloos, K. Ivanova Physica A, 286 (2000), p. 353

H.E. Hurst, R.P. Black, Y.M. Simaika Long-Term Storage, An Experimental Study, Constable, London (1965)

Examples

#The following examples using the database of financial time series
#collected during the United States bear market of 2007-2009.

library(DFA)
data("NYA2008")
file = NYA2008

DFA(file,scale = 2^(1/8),box_size = c(4,8,16),m=1)


# Example with different polynomial fit order.

library(DFA)
data("LSE.L2008")
file = LSE.L2008

DFA(file,scale = 2^(1/8),box_size = c(4,8,16),m=2)


# Example using different choice of overlapping boxes sizes.

library(DFA)
data("NYA2008")
file = NYA2008

DFA(file,scale = "F",box_size = c(4,8,16),m=1)

A single DFA dataframe with the decimal log fluctuation curve.

Description

The data contains the log fluctuation channel curve calculated for an epileptic subject extracted in the Physionet platform.

Usage

data("EEGsignal")

Format

A data frame with 91 observations on the following 2 variables.

⁠log10(boxes)⁠

a numeric vector referring to the decimal logarithm of the boxes sizes.

⁠log10(DFA)⁠

a numeric vector referring to the decimal logarithm of the Detrended Fluctuation Analysis (DFA) calculated in each boxe.

References

https://physionet.org/content/chbmit/1.0.0/chb01/#files-panel

Examples

data(EEGsignal)
data("EEGsignal")
x<-EEGsignal$`log10(boxes)`
y<-EEGsignal$`log10(DFA)`
plot(x,y)

euclidean method for detection of crossover points

Description

Applies the euclidean method for detection of crossover points on the log-log curve.

Usage

euclidean(x,y,npoint)

Arguments

x

Vector of the decimal logarithm of the boxes sizes.

y

Vector of the decimal logarithm of the DFA calculated in each boxe.

npoint

Number of crossover points calculated on the log-log curve.

Value

position

Position of the crossover point identified by the euclidean method.

sugestion_before

Sugestion for the position of the second crossover point identified by the euclidean method and calculated in the area before the first crossover point.

sugestion_after

Sugestion for the position of the second crossover point identified by the euclidean method and calculated in the area after the first crossover point.

Author(s)

Victor Barreto Mesquita

References

https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line

Examples

# Example with crossover point fixed in position=20.

library(DFA)
data(lrcorrelation)
x<-lrcorrelation$`log10(boxes)`
y<-c(lrcorrelation$`log10(DFA(alpha = 0.1))`[1:20],lrcorrelation$`log10(DFA(alpha = 0.3))`[21:40])
plot(x,y,xlab="log10(boxes)",ylab="log10(DFA)",pch=19)
fit<- lm(y[1:20] ~ x[1:20])
fit2<-lm(y[21:40] ~ x[21:40])
abline(fit,col="blue")
abline(fit2,col="red")
euclidean(x,y,npoint=1)

# Example with crossover point fixed in position=13 and 26.
library(DFA)
data(lrcorrelation)
x<-lrcorrelation$`log10(boxes)`
y<-c(lrcorrelation$`log10(DFA(alpha = 0.2))`[1:13],lrcorrelation$`log10(DFA(alpha = 0.6))`[14:26]
  ,lrcorrelation$`log10(DFA(alpha = 0.9))`[27:40])
plot(x,y,xlab="log10(boxes)",ylab="log10(DFA)",pch=19)
fit<- lm(y[1:13] ~ x[1:13])
fit2<-lm(y[14:26] ~ x[14:26])
fit3<-lm(y[27:40] ~ x[27:40])
abline(fit,col="blue")
abline(fit2,col="red")
abline(fit3,col="brown")
euclidean(x,y,npoint=2)

Time series referring to the adjusted closing price of the NASDAQ Composite (^IXIC) during the United States bear market of 2007-2009

Description

Univariate vector of time series referring to the adjusted closing price of the NASDAQ Composite (^IXIC) during the United States bear market of 2007-2009, considered the worst bear market this side of the Great Depression. The crash, which unfolded from Oct. 9, 2007 to March 9, 2009, obliterated more than half of the total value of the U.S. stock market. During this period, the S&P 500 lost approximately a half of its value and threatened the very existence of iconic companies from General Motors to Merrill Lynch.

Usage

data("IXIC2008")

Format

The format is: num [1:332] 2811 2772 2805 2780 2763 ...

Source

Yahoo Finance

References

https://money.com/bear-market-anniversary/

Examples

library(DFA)
data("IXIC2008")

data frame with log fluctuation channel curve simulated following an ARFIMA process

Description

The data contains the data frame with log fluctuation channel curve simulated following an ARFIMA process with different DFA exponents ranging from short 0.1 to long 0.9 .

Usage

data("lrcorrelation")

Format

A data frame with 40 observations on the following 10 variables.

⁠log10(boxes)⁠

a numeric vector referring to the decimal logarithm of the boxes sizes.

⁠log10(DFA(alpha = 0.1))⁠

a numeric vector referring to the decimal logarithm of the Detrended Fluctuation Analysis (DFA) with DFA exponent equal 0.1 and calculated in each boxe.

⁠log10(DFA(alpha = 0.2))⁠

a numeric vector referring to the decimal logarithm of the Detrended Fluctuation Analysis (DFA) with DFA exponent equal 0.2 and calculated in each boxe.

⁠log10(DFA(alpha = 0.3))⁠

a numeric vector referring to the decimal logarithm of the Detrended Fluctuation Analysis (DFA) with DFA exponent equal 0.3 and calculated in each boxe.

⁠log10(DFA(alpha = 0.4))⁠

a numeric vector referring to the decimal logarithm of the Detrended Fluctuation Analysis (DFA) with DFA exponent equal 0.4 and calculated in each boxe.

⁠log10(DFA(alpha = 0.5))⁠

a numeric vector referring to the decimal logarithm of the Detrended Fluctuation Analysis (DFA) with DFA exponent equal 0.5 and calculated in each boxe.

⁠log10(DFA(alpha = 0.6))⁠

a numeric vector referring to the decimal logarithm of the Detrended Fluctuation Analysis (DFA) with DFA exponent equal 0.6 and calculated in each boxe.

⁠log10(DFA(alpha = 0.7))⁠

a numeric vector referring to the decimal logarithm of the Detrended Fluctuation Analysis (DFA) with DFA exponent equal 0.7 and calculated in each boxe.

⁠log10(DFA(alpha = 0.8))⁠

a numeric vector referring to the decimal logarithm of the Detrended Fluctuation Analysis (DFA) with DFA exponent equal 0.8 and calculated in each boxe.

⁠log10(DFA(alpha = 0.9))⁠

a numeric vector referring to the decimal logarithm of the Detrended Fluctuation Analysis (DFA) with DFA exponent equal 0.9 and calculated in each boxe.

Examples

library(DFA)
#library(latex2exp) # it is necessary for legend of the plot function
data(lrcorrelation)
plot(lrcorrelation$`log10(boxes)`,lrcorrelation$`log10(DFA(alpha = 0.9))`
     ,xlab="log10(n)",ylab="log10FDFA(n)",col="black"
     ,pch=19, ylim= c(-0.8,1.2))
lines(lrcorrelation$`log10(boxes)`,lrcorrelation$`log10(DFA(alpha = 0.8))`,type="p"
      ,col="blue", pch=19)
lines(lrcorrelation$`log10(boxes)`,lrcorrelation$`log10(DFA(alpha = 0.7))`,type="p"
      ,col="red", pch=19)
lines(lrcorrelation$`log10(boxes)`,lrcorrelation$`log10(DFA(alpha = 0.6))`,type="p"
      ,col="green", pch=19)
lines(lrcorrelation$`log10(boxes)`,lrcorrelation$`log10(DFA(alpha = 0.5))`,type="p"
      ,col="brown", pch=19)
lines(lrcorrelation$`log10(boxes)`,lrcorrelation$`log10(DFA(alpha = 0.4))`,type="p"
      ,col="yellow", pch=19)
lines(lrcorrelation$`log10(boxes)`,lrcorrelation$`log10(DFA(alpha = 0.3))`,type="p"
      ,col="orange", pch=19)
lines(lrcorrelation$`log10(boxes)`,lrcorrelation$`log10(DFA(alpha = 0.2))`,type="p"
      ,col="pink", pch=19)
lines(lrcorrelation$`log10(boxes)`,lrcorrelation$`log10(DFA(alpha = 0.1))`,type="p"
      ,col="magenta", pch=19)

#legend("bottom", legend=c(TeX("$\alpha_{DFA} = 0.9$"),TeX("$\alpha_{DFA} = 0.8$")
#                          ,TeX("$\alpha_{DFA} = 0.7$"),TeX("$\alpha_{DFA} = 0.6$")
#                          ,TeX("$\alpha_{DFA} = 0.5$"),TeX("$\alpha_{DFA} = 0.4$")
#                          ,TeX("$\alpha_{DFA} = 0.3$"),TeX("$\alpha_{DFA} = 0.2$")
#                          ,TeX("$\alpha_{DFA} = 0.1$"))
#       , col=c("black","blue","red","green","brown","yellow","orange","pink","magenta")
#       , pch=c(19,19,19,19,19,19,19,19,19)
#       , cex = 0.55
#       , ncol = 5
#)

Time series referring to the adjusted closing price of the London Stock Exchange Group plc (LSE.L) during the period which the United States faced the bear market of 2007-2009.

Description

Univariate vector of time series referring to the adjusted closing price of the London Stock Exchange Group plc (LSE.L) during the period which the United States faced the bear market of 2007-2009, considered the worst bear market this side of the Great Depression. The crash, which unfolded from Oct. 9, 2007 to March 9, 2009, obliterated more than half of the total value of the U.S. stock market. During this period, the S&P 500 lost approximately a half of its value and threatened the very existence of iconic companies from General Motors to Merrill Lynch.

Usage

data("LSE.L2008")

Format

The format is: num [1:332] 1172 1176 1165 1163 1163 ...

Source

Yahoo Finance

References

https://money.com/bear-market-anniversary/

Examples

library(DFA)
data("LSE.L2008")

Time series referring to the adjusted closing price of the NYSE COMPOSITE (^NYA) during the United States bear market of 2007-2009

Description

Univariate vector of time series referring to the adjusted closing price of the NYSE COMPOSITE (^NYA) during the United States bear market of 2007-2009, considered the worst bear market this side of the Great Depression. The crash, which unfolded from Oct. 9, 2007 to March 9, 2009, obliterated more than half of the total value of the U.S. stock market. During this period, the S&P 500 lost approximately a half of its value and threatened the very existence of iconic companies from General Motors to Merrill Lynch.

Usage

data("NYA2008")

Format

The format is: num [1:332] 10264 10245 10301 10216 10125 ...

Source

Yahoo Finance

References

https://money.com/bear-market-anniversary/

Examples

library(DFA)
data("NYA2008")

Detrended Cross-Correlation Coefficient (rhoDCCA)

Description

Applies the Detrended Cross-Correlation Coefficient (rhoDCCA) to nonstationary time series.

Usage

rhoDCCA(file,file2,scale = 2^(1/8),box_size = 4,m=1)

Arguments

file

Univariate time series (must be a vector or data frame)

file2

Univariate time series (must be a vector or data frame)

scale

Specifies the ratio between successive box sizes (by default scale = 2^(1/8))

box_size

Vector of box sizes (must be used in conjunction with scale = "F")

m

An integer of the polynomial order for the detrending (by default m=1).

Details

The Detrended Cross-Correlation Coefficient (rhoDCCA) can be computed in a geometric scale or for different choices of boxes sizes.

Value

boxe

Size nn of the overlapping boxes.

DFA1

DFA of the first time series (file).

DFA2

DFA of the second time series (file2).

DCCA

Detrended Cross-Correlation function.

rhoDCCA

Detrended Cross-Correlation Coefficient function, defined as the ratio between the DCCA and two DFA (DFA1,DFA2).

Note

The time series file and file2 must have the same sample size.

Author(s)

Victor Barreto Mesquita

References

Zebende G.F. DCCA cross-correlation coefficient: Quantifying level of cross-correlation Physica A, 390 (4) (2011), pp. 614-618

Vassoler R.T., Zebende G.F. DCCA cross-correlation coefficient apply in time series of air temperature and air relative humidity Physica A, 391 (7) (2012), pp. 2438-2443

Guedes E.F., Zebende G.F., da Cunha Lima I.C. Quantificacao dos Efeitos do Cambio na Producao da Industria de Transformacao Baiana: uma abordagem via coeficiente de correlacao cruzada rho dcca Conjuntura & Planejamento, 1 (192) (2017), pp. 75-89

Examples

#The following examples using the database of financial time series
#collected during the United States bear market of 2007-2009.

library(DFA)
data("NYA2008")
data("IXIC2008")
file = NYA2008
file2= IXIC2008

rhoDCCA(file,file2,scale = 2^(1/8),box_size = c(4,8,16),m=1)


# Example with different polynomial fit order.

library(DFA)
data("NYA2008")
data("LSE.L2008")
file = NYA2008
file2= LSE.L2008

rhoDCCA(file,file2,scale = 2^(1/8),box_size = c(4,8,16),m=2)


# Example using different choice of overlapping boxes sizes.

library(DFA)
data("NYA2008")
data("IXIC2008")
file = NYA2008
file2= IXIC2008

rhoDCCA(file,file2,scale = "F",box_size = c(4,8,16),m=1)

secant method for detection of crossover points

Description

Applies the secant method for detection of crossover points on the log-log curve.

Usage

secant(x,y,npoint,size_fit)

Arguments

x

Vector of the decimal logarithm of the boxes sizes.

y

Vector of the decimal logarithm of the DFA calculated in each boxe.

npoint

Number of crossover points calculated on the log-log curve.

size_fit

Number of points of the two semi-curved fitted in the extremes of the log-log curve.

Value

position

Position of the crossover point identified by the secant method.

Author(s)

Victor Barreto Mesquita

Examples

# Example with the data referring to the log fluctuation
#channel curve data calculated for an epileptic subject
#extracted in the Physionet platform.

library(DFA)
data("EEGsignal")
x<-EEGsignal$`log10(boxes)`
y<-EEGsignal$`log10(DFA)`
plot(x,y,xlab="log10(boxes)",ylab="log10(DFA)")

secant(x,y,npoint=2,size_fit=8)

# Example with crossover point fixed in position=20.

library(DFA)
part1 <- seq(1,20)
part2 <- seq(20,1)
y = c(part1,part2)
x<-seq(1,40)
plot(x,y)
secant(x,y,npoint=1,size_fit=8)

Time series referring to the adjusted closing price of the SSE Composite Index (^SSEC) during the period which the United States faced the bear market of 2007-2009.

Description

Univariate vector of time series referring to the adjusted closing price of the SSE Composite Index (^SSEC) during the period which the United States faced the bear market of 2007-2009, considered the worst bear market this side of the Great Depression. The crash, which unfolded from Oct. 9, 2007 to March 9, 2009, obliterated more than half of the total value of the U.S. stock market. During this period, the S&P 500 lost approximately a half of its value and threatened the very existence of iconic companies from General Motors to Merrill Lynch.

Usage

data("SSEC2008")

Format

The format is: num [1:332] 5771 5913 5903 6030 6092 ...

Source

Yahoo Finance

References

https://money.com/bear-market-anniversary/

Examples

library(DFA)
data("SSEC2008")