sdf.test: SDF Test

View source: R/sdftest-functions.R

sdf.testR Documentation

SDF Test

Description

Performs the test for equality of spectral densities of two time series.

Usage

sdf.test(
  X1,
  X2,
  Te,
  alpha,
  q1 = 4,
  method1 = "GCV",
  f1_true = NULL,
  q2 = q1,
  method2 = method1,
  f2_true = f1_true,
  N = 10000,
  cores = 1,
  nulldistr = NULL
)

Arguments

X1

Longest time series.

X2

Shortest time series.

Te

Integer. Number of bins.

alpha

Numeric. Significance level for the test.

q1

Integer. Penalisation order for X1, q=1,2,3,4,5,6 are available (default 4).

method1

Character. Method for selecting the smoothing parameter for X1 (default "GCV").

f1_true

Vector or NULL. True regression function evaluated at equi-spaced points. Required only if method1 is set to "GCV-oracle" or "ML-oracle".

q2

Integer. Penalization order for X2 (default q1).

method2

Character. Method for selecting the smoothing parameter for X2 (default method1).

f2_true

Vector or NULL. True regression function evaluated at equi-spaced points. Required only if method2 is set to "GCV-oracle" or "ML-oracle" (default f1_true).

N

Integer. Number of iterations for null distribution computa- tion (default 10000).

cores

Integer. Number of cores for parallel computation of null distribution (default 1).

nulldistr

Vector or NULL. Vector of empirical null distribution (default NULL).

Value

An object of class "test", which is a list containing the following components:

result

Logical. TRUE if the null hypothesis of equality of spectral densities is not rejected by the test, FALSE otherwise.

S

Value of the statistic.

quantile

Empirical quantile used for the test.

pval

p-value of the test according to the empirical null distribution.

nulldistr

Vector of empirical null distribution.

References

Nadin, Krivobokova, Enikeeva (2026). Nonparametric two sample test of spectral densities. https://arxiv.org/abs/2602.10774

See Also

demo("eeg", package = "sdf.test") for the EEG application from Nadin, Krivobokova, Enikeeva (2026).

Examples

# --- Example 1: Using random data ---
test <- sdf.test(
  X1 = rnorm(100), X2 = rnorm(80),
  q1 = 4, method1 = "GCV", Te = 20, alpha = 0.05, N = 1000
)
test

# --- Example 2: Using random data ---

X1 <- arima.sim(list(order=c(1,0,0),ar=0.5),n = 1200,rand.gen = rnorm, sd = 1)
X2 <- arima.sim(list(order=c(1,0,0),ar=0.8),n = 1000,rand.gen = rnorm, sd = 1)
sdf.test(
  X1 = X1, X2 = X2,
  q1 = 4, method1 = "GCV", Te = 176, alpha = 0.05
)


# --- Example 3: Using EEG dataset ---
# Takes a long time; run it with:
# demo("eeg", package = "sdf.test")


sdf.test documentation built on Dec. 2, 2026, 5:07 p.m.