Title: Testing True Long Memory Against Spurious Long Memory
Version: 1.0.0
Maintainer: Zhongjun Qu <qu@bu.edu>
Description: Implements a test for distinguishing between true long memory and spurious long memory. Reference: Qu, Z. (2011). "A Test Against Spurious Long Memory." Journal of Business & Economic Statistics, 29(3), 423–438. <doi:10.1198/jbes.2010.09153>.
License: GPL (≥ 3)
Depends: R (≥ 4.3.0)
Suggests: knitr, rmarkdown
VignetteBuilder: knitr
Encoding: UTF-8
NeedsCompilation: no
RoxygenNote: 7.3.2
Imports: fracdiff, stats
LazyData: true
Packaged: 2025-11-25 18:47:36 UTC; qu
Author: Zhongjun Qu [aut, cre], Cheolju Kim [aut]
Repository: CRAN
Date/Publication: 2025-12-01 14:40:21 UTC

Testing true long memory against spurious long memory

Description

Tests the null hypothesis of true long memory against the alternative of spurious long memory (e.g., due to level shifts or trends) using the Qu (2011) test.

Usage

Longmemorytest(
  x,
  demean = TRUE,
  alpha = 0.05,
  filter = TRUE,
  print_results = TRUE
)

Arguments

x

Numeric vector of time series data

demean

Logical, demean the series (default: TRUE)

alpha

Numeric, significance level: 0.01, 0.025, 0.05, or 0.10 (default: 0.05)

filter

Logical, apply a pre-whitening filter to reduce short-memory dynamics that may otherwise affect the size of the test in finite samples (default: TRUE).

print_results

Logical, print results (default: TRUE)

Details

The test uses bandwidth parameter m = n^0.7 with trimming parameters 0.02 or 0.05 as recommended by Qu (2011). Critical values are based on these settings. Whether the pre-whitening filter is applied does not affect the asymptotic critical values.

Value

A list with elements:

d_estimate

Local Whittle estimate of the long memory parameter.

test_stat_eps02

Test statistic with trimming parameter epsilon = 0.02.

test_stat_eps05

Test statistic with trimming parameter epsilon = 0.05.

critical_value_eps02

Critical value for epsilon = 0.02 at the chosen significance level alpha.

critical_value_eps05

Critical value for epsilon = 0.05 at the chosen significance level alpha.

reject_eps02

Logical, TRUE if the null is rejected for epsilon = 0.02.

reject_eps05

Logical, TRUE if the null is rejected for epsilon = 0.05.

alpha

Significance level.

m

Bandwidth parameter m.

n

Sample size.

References

Qu, Z. (2011). A Test Against Spurious Long Memory. Journal of Business & Economic Statistics, 29(3), 423-438.

Examples

data(RV5min)
result <- Longmemorytest(log(RV5min))

# Simulated example: ARFIMA(0,d,0) with d = 0.3 (true long memory)
set.seed(123)
n  <- 2000
d0 <- 0.3
e  <- rnorm(n)
x  <- fracdiff::fracdiff.sim(n, d = d0)$series

# Apply the test (null = true long memory)
out <- Longmemorytest(x, alpha = 0.05)
out$reject_eps02    # typically FALSE
out$d_estimate

# Example: Spurious long memory due to a structural break
set.seed(123)
n <- 2000
x <- c(rnorm(n/2, 0, 1), rnorm(n/2, 2, 1))   # one-time mean shift

out <- Longmemorytest(x, alpha = 0.05)
out$reject_eps02
out$reject_eps05


RV5min: realized volatility for Japanese Yen/USD spot exchange rates from Dec 1st, 1986 to Jun 30th, 1999

Description

RV5min: realized volatility for Japanese Yen/USD spot exchange rates from Dec 1st, 1986 to Jun 30th, 1999

Usage

data(RV5min)

Format

Numeric vector


Filter a time series to reduce the short-memory dynamics using a low-order ARFIMA model

Description

Fits ARFIMA(p, d, q) models with p, q \in \{0, 1\} using fracdiff, selects the specification by AIC, and applies the corresponding linear filter to the series.

Usage

filterx(x, n = NULL)

Arguments

x

A numeric vector containing the time series to be filtered.

n

An integer giving the length of the filtered series. If NULL, the length of x is used.

Details

The function considers ARFIMA(1, d, 1), ARFIMA(1, d, 0), ARFIMA(0, d, 1), and ARFIMA(0, d, 0) models, computes AIC for each, and selects the model with the smallest AIC. If the absolute value of the selected AR or MA coefficient is greater than or equal to 0.99, the procedure selects a pure fractional model ARFIMA(0, d, 0). The input series is centered before estimation.

Value

A numeric vector of length n containing the filtered series.

Examples

set.seed(123)
sim <- fracdiff::fracdiff.sim(
n = 1000,
ar = 0.3,     # AR(1) coefficient
ma = -0.4,    # MA(1) coefficient
d  = 0.25     # fractional differencing parameter
)
x <- sim$series
y <- filterx(x)