Type: Package
Title: Change Point Tests for Joint Distributions and Copulas
Version: 0.1.7
Maintainer: Bruno N Remillard <bruno.remillard@hec.ca>
Description: Change point tests for joint distributions and copulas using pseudo-observations with multipliers or bootstrap. The processes used here have been defined in Bucher, Kojadinovic, Rohmer & Segers <doi:10.1016/j.jmva.2014.07.012> and Nasri & Remillard <doi:10.1016/j.jmva.2019.03.002>.
License: GPL-3
Encoding: UTF-8
LazyData: true
Depends: R (≥ 3.5.0), doParallel, parallel, foreach, stats
RoxygenNote: 7.3.2
NeedsCompilation: yes
Packaged: 2024-09-23 14:42:37 UTC; 49009427
Author: Bouchra R Nasri [aut], Bruno N Remillard [aut, cre, cph]
Repository: CRAN
Date/Publication: 2024-09-23 15:00:07 UTC

Function to perform traditional bootstrap for changepoint

Description

This function select a bootstrap sample of indices and compute the Cramer-von Mises and Kolmogorov-Smirnov test statistics for changepoint

Usage

bootstrapfun(X, n)

Arguments

X

n x d matrix of pseudo-observations;

n

length of the series.

Value

cvm

simulated value of the Cramer-von Mises statistic

ks

simulated value of the Kolmogorov-Smirnov statistic


Function to compute changepoint statistics

Description

This function is used to compute the Cramer-von Mises and Kolmogorov-Smirnov test statistics for changepoint

Usage

cpCopDStats(U, n, d)

Arguments

U

n x d matrix of pseudo-observations

n

length of the series

d

number of variables

Value

statS

Values of the Cramer-von Mises statistics

statT

Values of the Kolmogorov-Smirnov statistics

Author(s)

Bouchra R Nasri and Bruno N Remillard, August 6, 2020


Function to compute bootstrapped changepoint statistics

Description

This function compute bootstrapped multipliers values for the Cramer-von Mises and Kolmogorov-Smirnov test statistics for changepoint

Usage

cpCopMultStats(MC, xi, s, n)

Arguments

MC

matrix needed for multipliers

xi

multipliers

s

sequence of normalized values in (0,1)

n

length of the series

Value

statS

Simulated values of the Cramer-von Mises statistics

statT

Simulated values of the Kolmogorov-Smirnov statistics

Author(s)

Bouchra R Nasri and Bruno N Remillard, August 6, 2020


Function to compute the bootstrapped statistics for the BKRS process

Description

This function is used to compute bootstrapped statistics from the BKRS process in the non-sequential case

Usage

cpCopMultStatsBKRSNonSeq(MC, MC1, grad, xi, s, n, d)

Arguments

MC

matrix needed for multipliers

MC1

matrices needed for multipliers

grad

gradient of the copula

xi

multipliers

s

sequence of normalized values in (0,1)

n

length of the series

d

number of variables

Value

statS

Values of the Cramer-von Mises statistics

statT

Values of the Kolmogorov-Smirnov statistics

Author(s)

Bouchra R Nasri and Bruno N Remillard, August 6, 2020


Function to compute the statistics for the BKRS process

Description

This function is used to compute bootstrapped statistics from the BKRS process in the sequential case

Usage

cpCopMultStatsBKRSSeq(U, grad, xi, n, d)

Arguments

U

matrix needed for multipliers

grad

gradient of the copula

xi

multipliers

n

length of the series

d

number of variables

Value

statS

Values of the Cramer-von Mises statistics

statT

Values of the Kolmogorov-Smirnov statistics

Author(s)

Bouchra R Nasri and Bruno N Remillard, August 6, 2020


Function to compute the statistics for the traditional empirical process

Description

This function is used to compute the empirical process used in the changepoint tests

Usage

cpCopStats(x)

Arguments

x

n x d matrix of pseudo-observations

Value

M

Matrix for the cdf

statS

Values of the Cramer-von Mises statistics

statT

Values of the Kolmogorov-Smirnov statistics

Author(s)

Bouchra R Nasri and Bruno N Remillard, August 6, 2020


Function to compute the statistics for the BKRS process

Description

This function is used to compute the empirical process used in the changepoint tests

Usage

cpCopStatsBKRS(x, n, d)

Arguments

x

n x d matrix of pseudo-observations

n

length of the series

d

number of variables

Value

MC

Matrix needed for multipliers

MC1

Matrices needed for multipliers

grad1

Esatimated gradient of the copula

Author(s)

Bouchra R Nasri and Bruno N Remillard, August 6, 2020


Function to compute the empirical cdf at given points

Description

This function is used to compute the empirical process used in the changepoint tests

Usage

emp.cdf(x, u)

Arguments

x

n x d matrix of pseudo-observations

u

evaluation points of the cdf

Value

M

Values of the empirical process

cumsum

Associated cumulativ sums

Author(s)

Bouchra R Nasri and Bruno N Remillard, August 6, 2020


Function to perform multiplier bootstrap for changepoint

Description

This function simulates a random sample of Gaussian multipliers null hypothesis of a Gaussian HMM and compute the Cramer-von Mises and Kolmogorov-Smirnov test statistics.

Usage

multiplierDNonSeqfun(MC, MC1, grad, s, n, d)

Arguments

MC

matrix needed for multipliers

MC1

matrices needed for multipliers

grad

gradient of the copula

s

sequence of normalized values in (0,1)

n

length of the series

d

number of variables

Value

cvm

simulated value of the Cramer-von Mises statistic

ks

simulated value of the Kolmogorov-Smirnov statistic

Author(s)

Bouchra R Nasri and Bruno N Remillard, August 6, 2020

References

Nasri, B. R. Remillard, B., & Bahraoui, T. (2022).


Function to perform multiplier bootstrap for changepoint

Description

This function simulates a random sample of Gaussian multipliers null hypothesis of a Gaussian HMM and compute the Cramer-von Mises and Kolmogorov-Smirnov test statistics.

Usage

multiplierDSeqfun(U, grad, n, d)

Arguments

U

matrix needed for multipliers

grad

gradient of the copula

n

length of the series

d

number of variables.

Value

cvm

simulated value of the Cramer-von Mises statistic

ks

simulated value of the Kolmogorov-Smirnov statistic

Author(s)

Bouchra R Nasri and Bruno N Remillard, August 6, 2020

References

Nasri, B. R. Remillard, B., & Bahraoui, T. (2022).


Function to perform multiplier bootstrap for changepoint

Description

This function simulates a random sample of Gaussian multipliers null hypothesis of a Gaussian HMM and compute the Cramer-von Mises and Kolmogorov-Smirnov test statistics.

Usage

multiplierfun(MC, s, n)

Arguments

MC

n x n matrix = MM - C, with MM[i,j] = 1(Xi <= Xj) and C=mean(M[,j]);

n

length of the series.

Value

cvm

simulated value of the Cramer-von Mises statistic

ks

simulated value of the Kolmogorov-Smirnov statistic

Author(s)

Bouchra R Nasri and Bruno N Remillard, August 6, 2020

References

Chapter 8 of B. Remillard (2013). Statistical Methods for Financial Engineering, Chapman and Hall/CRC Financial Mathematics Series, Taylor & Francis.


Pseudo-observations

Description

Pseudo-observations used in Nasri, Remillard, Bahraoui (2021). The values represent conditional cdfs of Gaussian HMM models applied to log-returns of Nasdaq and Dow Jones Industrial indexes from 2007 and 2008. If the models are correct, the pseudo-observations should be almost iid with uniform distribution.

Usage

data(pseudos)

Format

Pseudo-observations from Gaussian HMM models with 3 regimes for log-returns of the to Nasdaq index and Dow Jones Industrial indexes from 2007 and 2008.


Function to perform changepoint tests with multiplier bootstrap using the usual sequential process

Description

This function compute the Cramer-von Mises and Kolmogorov-Smirnov test statistics based on the new sequential process of Bucher et al (2014), using multipliers and parallel computing.

Usage

test.change.point(
  x,
  N = 1000,
  n_cores = 2,
  boot.method = "multipliers",
  est = FALSE
)

Arguments

x

(n x d) matrix of data (observations or pseudo-observations, including residuals), d>=1

N

number of multipliers samples to compute the P-value

n_cores

number of cores for parallel computing (default = 2)

boot.method

bootstrapping method: 'multipliers' (default, fastest) or 'bootstrap'

est

if TRUE, tau is estimated (default = FALSE)

Value

CVM

Cramer-von Mises statistic

KS

Kolmogorov-Smirnov statistic

pvalueCVM

Pvalue for the Cramer-von Mises statistic

pvalueKS

Pvalue for theKolmogorov-Smirnov statistic

tauCVM

Estimated changepoint using the Cramer-von Mises statistic

tauKS

Estimated changepoint using the Kolmogorov-Smirnov statistic

Author(s)

Bouchra R Nasri and Bruno N Remillard, August 6, 2020

References

Nasri, B. R. Remillard, B., & Bahraoui, T. (2022). Change-point problems for multivariate time series using pseudo-observations, J. Multivariate Anal., 187, 104857.

Examples

x=matrix(rnorm(600),ncol=3)
out = test.change.point(x)



Function toperform changepoint test for the copula with multiplier bootstrap using for changepoint the new sequential process of Bucher et al (2014)

Description

This function compute the Cramer-von Mises and Kolmogorov-Smirnov test statistics based on the new sequential process of Bucher et al (2014), using multipliers and parallel computing. Two methods of bootstrapping are used: non-sequential (fastest) and sequential. Both methods yields basically the same P-valueas.

Usage

test.change.point.copula.BKRS(
  x,
  N = 1000,
  n_cores = 2,
  method = "nonseq",
  est = FALSE
)

Arguments

x

(n x d) matrix of data (observations or pseudo-observations, including residuals), d >=2

N

number of multipliers samples to compute the P-value

n_cores

number of cores for parallel computing (default = 2)

method

'nonseq' (default) or 'seq'

est

if TRUE, tau is estimated (default = FALSE)

Value

CVM

Cramer-von Mises statistic

KS

Kolmogorov-Smirnov statistic

pvalueCVM

Pvalue for the Cramer-von Mises statistic

pvalueKS

Pvalue for theKolmogorov-Smirnov statistic

tauCVM

Estimated changepoint using the Cramer-von Mises statistic

tauKS

Estimated changepoint using the Kolmogorov-Smirnov statistic

Author(s)

Bouchra R Nasri and Bruno N Remillard, August 6, 2020

References

Nasri, B. R. Remillard, B., & Bahraoui, T. (2022). Change-point problems for multivariate time series using pseudo-observations, J. Multivariate Anal., 187, 104857.

Bucher, A., Kojadinovic, I., Rohmer, T., & Segers, J. (2014). Detecting changes in cross-sectional dependence in multivariate time series, J. Multiv. Anal., 132, 111–128.

Examples

x<-matrix(rnorm(100),ncol=2)
out = test.change.point.copula.BKRS(x)