Package 'testcorr'

Title: Testing Zero Correlation
Description: Computes the test statistics for examining the significance of autocorrelation in univariate time series, cross-correlation in bivariate time series, Pearson correlations in multivariate series and test statistics for i.i.d. property of univariate series given in Dalla, Giraitis and Phillips (2020), <https://cowles.yale.edu/sites/default/files/files/pub/d21/d2194-r.pdf>.
Authors: Violetta Dalla, Liudas Giraitis and Peter C. B. Phillips
Maintainer: Violetta Dalla <[email protected]>
License: GPL-3
Version: 0.2.0
Built: 2025-02-20 03:59:38 UTC
Source: https://github.com/cran/testcorr

Help Index


Testing zero autocorrelation

Description

The function ac.test computes the test statistics for examining the null hypothesis of zero autocorrelation for univariate time series given in Dalla, Giraitis and Phillips (2020).

Usage

ac.test(x, max.lag, alpha = 0.05, lambda = 2.576, plot = TRUE,
        table = TRUE, var.name = NULL, scale.font = 1)

Arguments

x

A numeric vector or a univariate numeric time series object or a data frame.

max.lag

Maximum lag at which to calculate the test statistics.

alpha

Significance level for hypothesis testing used in the plots. Default is 0.05.

lambda

Threshold in Q~\widetilde{Q} test statistics. Default is 2.576.

plot

Logical. If TRUE the sample autocorrelations with their confidence bands and the cumulative statistics with their critical values are plotted. Default is TRUE.

table

Logical. If TRUE the sample autocorrelations, the confidence bands, the test statistics and their p-values are printed out. Default is TRUE.

var.name

NULL or a character string specifying the variable name. If NULL and x has name, the name of x is used. If NULL and x has no name, the string "x" is used. Default is NULL.

scale.font

A positive number indicating the scaling of the font size in the plots. Default is 1.

Details

The standard tt and robust t~\widetilde{t} statistics are for testing the null hypothesis H0:ρk=0H_0:\rho_k=0 at lags k=1,...,max.lagk=1,...,max.lag, and the standard LBLB and robust Q~\widetilde{Q} statistics are for testing the null hypothesis H0:ρ1=...=ρm=0H_0:\rho_1=...=\rho_m=0 at lags m=1,...,max.lagm=1,...,max.lag, where ρk\rho_k denotes the autocorrelation of xtx_t at lag kk.

Value

An object of class "ac.test", which is a list with the following components:

lag

The lags used.

ac

The sample autocorrelations.

scb

The lower and upper limit of the confidence bands based on the standard test statistics.

rcb

The lower and upper limit of the confidence bands based on the robust test statistics.

t

The tt test statistics.

pvt

The p-values for the tt test statistics.

ttilde

The t~\widetilde{t} test statistics.

pvttilde

The p-values for the t~\widetilde{t} test statistics.

lb

The LBLB test statistics.

pvlb

The p-values for the LBLB test statistics.

qtilde

The Q~\widetilde{Q} test statistics.

pvqtilde

The p-values for the Q~\widetilde{Q} test statistics.

Note

Missing values are not allowed.

Author(s)

Violetta Dalla, Liudas Giraitis and Peter C. B. Phillips

References

Dalla, V., Giraitis, L. and Phillips, P. C. B. (2020). "Robust Tests for White Noise and Cross-Correlation". Cowles Foundation, Discussion Paper No. 2194, https://cowles.yale.edu/sites/default/files/files/pub/d21/d2194-r.pdf.

Examples

x <- rnorm(100)
ac.test(x, max.lag = 10)

Testing zero cross-correlation

Description

The function cc.test computes the test statistics for examining the null hypothesis of zero cross-correlation for bivariate time series given in Dalla, Giraitis and Phillips (2020).

Usage

cc.test(x, y, max.lag, alpha = 0.05, lambda = 2.576, plot = TRUE,
        table = TRUE, var.names = NULL, scale.font = 1)

Arguments

x

A numeric vector or a univariate numeric time series object or a data frame.

y

A numeric vector or a univariate numeric time series object or a data frame.

max.lag

Maximum lag at which to calculate the test statistics.

alpha

Significance level for hypothesis testing used in the plots. Default is 0.05.

lambda

Threshold in Q~\widetilde{Q} test statistics. Default is 2.576.

plot

Logical. If TRUE the sample cross-correlations with their confidence bands and the cumulative statistics with their critical values are plotted. Default is TRUE.

table

Logical. If TRUE the sample cross-correlations, the confidence bands, the test statistics and their p-values are printed out. Default is TRUE.

var.names

NULL or a character string specifying the variable names. If NULL and x,y have names, the names of x,y are used. If NULL and x,y have no names, the string c("x","y") is used. Default is NULL.

scale.font

A positive number indicating the scaling of the font size in the plots. Default is 1.

Details

The standard tt and robust t~\widetilde{t} statistics are for testing the null hypothesis H0:ρk=0H_0:\rho_k=0 at lags k=max.lag,...,1,0,1,max.lagk=-max.lag,...,-1,0,1,max.lag, and the standard HBHB and robust Q~\widetilde{Q} statistics are for testing the null hypothesis H0:ρ0=...=ρm=0H_0:\rho_0=...=\rho_m=0 at lags m=max.lag,...,1,0,1,max.lagm=-max.lag,...,-1,0,1,max.lag, where ρk\rho_k denotes the cross-correlation of xtx_t and ytky_{t-k} at lag kk.

Value

An object of class "cc.test", which is a list with the following components:

lag

The lags used.

cc

The sample cross-correlations.

scb

The lower and upper limit of the confidence bands based on the standard test statistics.

rcb

The lower and upper limit of the confidence bands based on the robust test statistics.

t

The tt test statistics.

pvt

The p-values for the tt test statistics.

ttilde

The t~\widetilde{t} test statistics.

pvtttilde

The p-values for the t~\widetilde{t} test statistics.

hb

The HBHB test statistics.

pvhb

The p-values for the HBHB test statistics.

qtilde

The Q~\widetilde{Q} test statistics.

pvqtilde

The p-values for the Q~\widetilde{Q} test statistics.

Note

Missing values are not allowed.

Author(s)

Violetta Dalla, Liudas Giraitis and Peter C. B. Phillips

References

Dalla, V., Giraitis, L. and Phillips, P. C. B. (2020). "Robust Tests for White Noise and Cross-Correlation". Cowles Foundation, Discussion Paper No. 2194, https://cowles.yale.edu/sites/default/files/files/pub/d21/d2194-r.pdf.

Examples

x <- rnorm(100)
y <- rnorm(100)
cc.test(x, y, max.lag = 10)

Testing iid property

Description

The function iid.test computes the test statistics for examining the null hypothesis of i.i.d. property for univariate series given in Dalla, Giraitis and Phillips (2020).

Usage

iid.test(x, max.lag, alpha = 0.05, plot = TRUE, table = TRUE,
         var.name = NULL, scale.font = 1)

Arguments

x

A numeric vector or a univariate numeric time series object or a data frame.

max.lag

Maximum lag at which to calculate the test statistics.

alpha

Significance level for hypothesis testing used in the plots. Default is 0.05.

plot

Logical. If TRUE the test statistics and their critical values are plotted. Default is TRUE.

table

Logical. If TRUE the test statistics and their p-values are printed out. Default is TRUE.

var.name

NULL or a character string specifying the variable name. If NULL and x has name, the name of x is used. If NULL and x has no name, the string "x" is used. Default is NULL.

scale.font

A positive number indicating the scaling of the font size in the plots. Default is 1.

Details

The Jx,xJ_{x,|x|} and Jx,x2J_{x,x^2} statistics are for testing the null hypothesis of i.i.d. at lag kk, k=1,...,max.lagk=1,...,max.lag, and the Cx,xC_{x,|x|} and Cx,x2C_{x,x^2} statistics are for testing the null hypothesis of i.i.d. at lags 1,...,m1,...,m, m=1,...,max.lagm=1,...,max.lag.

Value

An object of class "iid.test", which is a list with the following components:

lag

The lags used.

jab

The Jx,xJ_{x,|x|} test statistics.

pvjab

The p-values for the Jx,xJ_{x,|x|} test statistics.

jsq

The Jx,x2J_{x,x^2} test statistics.

pvjsq

The p-values for the Jx,x2J_{x,x^2} test statistics.

cab

The Cx,xC_{x,|x|} test statistics.

pvcab

The p-values for the Cx,xC_{x,|x|} test statistics.

csq

The Cx,x2C_{x,x^2} test statistics.

pvcsq

The p-values for the Cx,x2C_{x,x^2} test statistics.

Note

Missing values are not allowed.

Author(s)

Violetta Dalla, Liudas Giraitis and Peter C. B. Phillips

References

Dalla, V., Giraitis, L. and Phillips, P. C. B. (2020). "Robust Tests for White Noise and Cross-Correlation". Cowles Foundation, Discussion Paper No. 2194, https://cowles.yale.edu/sites/default/files/files/pub/d21/d2194-r.pdf.

Examples

x <- rnorm(100)
iid.test(x, max.lag = 10)

Testing zero Pearson correlation

Description

The function rcorr.test computes the test statistics for examining the null hypothesis of zero Pearson correlation for multivariate series in Dalla, Giraitis and Phillips (2020).

Usage

rcorr.test(x, plot = TRUE, table = TRUE, var.names = NULL,
           scale.font = 1)

Arguments

x

A numeric matrix or a multivariate numeric time series object or a data frame.

plot

Logical. If TRUE the sample Pearson correlations and the p-values for significance are plotted. Default is TRUE.

table

Logical. If TRUE the sample Pearson correlations and the p-values for significance are printed out. Default is TRUE.

var.names

NULL or a character string specifying the variable names. If NULL and x has names, the names of x are used. If NULL and x has no names, the string c("x[1]","x[2]",...) is used. Default is NULL.

scale.font

A positive number indicating the scaling of the font size in the plots. Default is 1.

Details

The p-value of the robust t~\widetilde{t} statistic is for testing the null hypothesis H0:ρi,j=0H_0:\rho_{i,j}=0, where ρi,j\rho_{i,j} denotes the correlation of xix_{i} and xjx_{j}.

Value

An object of class "rcorr.test", which is a list with the following components:

pc

The sample Pearson correlations.

pv

The p-values for the t~\widetilde{t} test statistics.

Note

Missing values are not allowed.

Author(s)

Violetta Dalla, Liudas Giraitis and Peter C. B. Phillips

References

Dalla, V., Giraitis, L. and Phillips, P. C. B. (2020). "Robust Tests for White Noise and Cross-Correlation". Cowles Foundation, Discussion Paper No. 2194, https://cowles.yale.edu/sites/default/files/files/pub/d21/d2194-r.pdf.

Examples

x <- matrix(rnorm(400),100)
rcorr.test(x)