R/RcppExports.R

Defines functions compute_xi_acf_iaaft generate_iaaft_surrogates xi_coefficient compute_xi_matrix_miaaft compute_xi_ccf_miaaft generate_miaaft_surrogate_cpp

Documented in compute_xi_acf_iaaft compute_xi_ccf_miaaft compute_xi_matrix_miaaft generate_miaaft_surrogate_cpp xi_coefficient

# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

#' Generate a Single MIAAFT Surrogate Matrix
#'
#' @param x A numeric matrix (rows = time, cols = variables).
#' @param max_iter An integer specifying the maximum number of iterations.
#' @return A numeric matrix representing the generated MIAAFT surrogate.
#' @export
generate_miaaft_surrogate_cpp <- function(x, max_iter = 100L) {
    .Call(`_xiacf_generate_miaaft_surrogate_cpp`, x, max_iter)
}

#' Compute MIAAFT-based Directional Xi-CCF
#'
#' @param x First time series (numeric vector, potential cause)
#' @param y Second time series (numeric vector, potential effect)
#' @param max_lag Maximum positive lag to evaluate
#' @param n_surr Number of surrogate datasets to generate
#' @return A list containing forward (X leads Y) and backward (Y leads X) Xi coefficients and surrogates.
#' @export
compute_xi_ccf_miaaft <- function(x, y, max_lag, n_surr) {
    .Call(`_xiacf_compute_xi_ccf_miaaft`, x, y, max_lag, n_surr)
}

#' Compute Pairwise Directional Xi-CCF for a Multivariate Matrix
#'
#' @param x A numeric matrix (rows = time, cols = variables).
#' @param max_lag An integer specifying the maximum positive lag.
#' @param n_surr An integer specifying the number of surrogate datasets.
#' @return A list containing flat vectors for lead/lag variable indices, lags, 
#'         original Xi values, and a matrix of surrogate Xi values.
#' @export
compute_xi_matrix_miaaft <- function(x, max_lag, n_surr) {
    .Call(`_xiacf_compute_xi_matrix_miaaft`, x, max_lag, n_surr)
}

#' Calculate Chatterjee's Rank Correlation Coefficient (Xi)
#' 
#' Computes Chatterjee's rank correlation coefficient (Xi) between two numeric vectors.
#' Ties are broken uniformly at random to ensure strict inequalities.
#' 
#' @param x A numeric vector.
#' @param y A numeric vector of the same length as \code{x}.
#' @return A numeric scalar representing the Chatterjee's Xi coefficient.
#' @export
xi_coefficient <- function(x, y) {
    .Call(`_xiacf_xi_coefficient`, x, y)
}

generate_iaaft_surrogates <- function(x, n_surr, max_iter = 100L) {
    .Call(`_xiacf_generate_iaaft_surrogates`, x, n_surr, max_iter)
}

#' Compute Xi-ACF for Multiple Lags (Core Engine)
#' 
#' Calculates Chatterjee's Xi coefficient for multiple lags and generates
#' IAAFT (Iterative Amplitude Adjusted Fourier Transform) surrogates to establish 
#' confidence intervals for non-linear dependence.
#' 
#' @param x A numeric vector (time series).
#' @param max_lag An integer specifying the maximum number of lags to compute.
#' @param n_surr An integer specifying the number of surrogate datasets to generate.
#' @return A list containing \code{xi_original} (the Xi coefficients for the original series) 
#' and \code{xi_surrogates} (a matrix of Xi coefficients for the surrogate datasets).
#' @export
compute_xi_acf_iaaft <- function(x, max_lag, n_surr) {
    .Call(`_xiacf_compute_xi_acf_iaaft`, x, max_lag, n_surr)
}

Try the xiacf package in your browser

Any scripts or data that you put into this service are public.

xiacf documentation built on April 16, 2026, 5:08 p.m.