Title: | Tests of Randomness and Tests of Independence |
---|---|
Description: | Functions for testing randomness for a univariate time series with arbitrary distribution (discrete, continuous, mixture of both types) and for testing independence between random variables with arbitrary distributions. The test statistics are based on the multilinear empirical copula and multipliers are used to compute P-values. The test of independence between random variables appeared in Genest, Nešlehová, Rémillard & Murphy (2019) and the test of randomness appeared in Nasri (2022). |
Authors: | Bouchra R. Nasri [aut, cre, cph], Bruno N Remillard [aut], Johanna G Neslehova [aut], Christian Genest [aut] |
Maintainer: | Bouchra R. Nasri <[email protected]> |
License: | GPL-3 |
Version: | 1.2.0 |
Built: | 2024-11-10 05:45:49 UTC |
Source: | https://github.com/cran/MixedIndTests |
This function, used in EstDepSerial, draws the P-values of Kendall's tau and Spearman's rho for a given number of lags.
AutoDep(out)
AutoDep(out)
out |
List of the output of EstDepSerial (P-values, subsets) |
B.R Nasri (2021). Tests of serial dependence for arbitrary distributions
out <-EstDepSerial(SimAR1Poisson(c(5,0.4),100),10) AutoDep(out)
out <-EstDepSerial(SimAR1Poisson(c(5,0.4),100),10) AutoDep(out)
This function, used in EstDep, TestIndCopula and TestIndSerCopula, draws the P-values of the Moebius Cramer-von Mises statistics from the multilinear copula and their combination for a tests of randomness for k consectives values X(1), ..., X(k) or for a test of independence between random variables.
Dependogram(out, stat = "CVM")
Dependogram(out, stat = "CVM")
out |
List of the output from EstDep, EstDepSerial, TestIndCopula or TestIndSerCopula (P-values, subsets) |
stat |
Name of statistics to be used (default is "CVM") |
Genest, Neslehova, Remillard & Murphy (2019). Testing for independence in arbitrary distributions
x <- matrix(rnorm(250),ncol=5) out <-TestIndCopula(x) Dependogram(out)
x <- matrix(rnorm(250),ncol=5) out <-TestIndCopula(x) Dependogram(out)
This function, used in EstDepMoebius and EstDepSerialMoebius plot the graphs of the correlation statistics of Spearman, van der Waerden and Savage as a function of the subsets for tests of randomness or test of independence between random variables. Under the null hypothesis, the statistics should be independent N(0,1).
DependogramZ(out, n)
DependogramZ(out, n)
out |
List of the output from EstDep, EstDepSerial, TestIndCopula or TestIndSerCopula (P-values, subsets) |
n |
Number of observations |
Nasri & Remillard (2023). Tests of independence and randomness for arbitrary data using copula-based covariances
x <- matrix(rnorm(250),ncol=5) out <-EstDepMoebius(x) DependogramZ(out,50)
x <- matrix(rnorm(250),ncol=5) out <-EstDepMoebius(x) DependogramZ(out,50)
This function computes the matrix of pairs of Kendall's tau and Spearman's rho statistics between random variables with arbitrary distributions.
EstDep(x, graph = FALSE)
EstDep(x, graph = FALSE)
x |
Data matrix |
graph |
Set to TRUE for a dependogram for all pairs of Kendall's taus and Spearman's rhos. |
stat |
List of Kendall's tau and Spearman's rho statistics from multilinear copula, and test combinations LB |
pvalue |
P-values for the tests statistics |
Genest, Neslehova, Remillard & Murphy (2018). Testing for independence in arbitrary distributions
x <- matrix(rnorm(500),ncol=10) out <-EstDep(x)
x <- matrix(rnorm(500),ncol=10) out <-EstDep(x)
This function computes copula-based dependence measures for Moebius versions of Spearmans's rho, van der Waerden's coefficient, and Savage's coefficient, as well as their combination for tests of independence between random variables.
EstDepMoebius(x, trunc.level = 2, graph = FALSE)
EstDepMoebius(x, trunc.level = 2, graph = FALSE)
x |
Data matrix |
trunc.level |
Only subsets of cardinality <= trunc.level (default=2) are considered for the Moebius statistics. |
graph |
Set to TRUE if one wants the dependogram of P-values for the Moebius statistics |
stat |
List of statistics (spearman, vdw, savage) and test combinations Ln and Ln2 (only pairs) |
pvalue |
P-values for the tests |
cardA |
Cardinaly of the subsets for the Moebius statistics |
subsets |
Subsets for the Moebius statistics |
B.R Nasri & B.N. Remillard (2023). Tests of independence and randomness for arbitrary data using copula-based covariances
x <- matrix(rnorm(250),ncol=5) out <-EstDepMoebius(x,3)
x <- matrix(rnorm(250),ncol=5) out <-EstDepMoebius(x,3)
This function computes Kendall's tau and Spearman's rho statistics for tests of randomness in a time series with arbitrary distribution for pairs (X[i],X[i+k]), k=1:lags
EstDepSerial(x, lag, graph = FALSE)
EstDepSerial(x, lag, graph = FALSE)
x |
Time series |
lag |
Number of lags |
graph |
Set to TRUE for a dependogram for Kendall's tau and Spearman;s rho |
stat |
List of Kendall's tau and Spearman's rho statistics from multilinear copula, and test combinations LB |
pvalue |
P-values for the tests statistics |
B.R Nasri (2022). Tests of serial dependence for arbitrary distributions
out <-EstDepSerial(SimAR1Poisson(c(5,0.4),100),10)
out <-EstDepSerial(SimAR1Poisson(c(5,0.4),100),10)
This function computes copula-based dependence measures for Moebius versions of Spearmans's rho, van der Waerden's coefficient, and Savage's coefficient, as well as their combination for tests of randomness for p consecutive values Y(1), ..., Y(p).
EstDepSerialMoebius(y, p, trunc.level = 2, graph = FALSE)
EstDepSerialMoebius(y, p, trunc.level = 2, graph = FALSE)
y |
Time series |
p |
Number of consecutive observations |
trunc.level |
Only subsets of cardinality <= trunc.level (default=2) are considered for the Moebius statistics. |
graph |
Set to TRUE if one wants the dependogram of P-values for the Moebius statistics |
stat |
List of statistics (spearman, vdw, savage) and test combinations Ln and Ln2 (only pairs) |
pvalue |
P-values for the tests |
card |
Cardinaly of the subsets for the Moebius statistics |
subsets |
Subsets for the Moebius statistics |
B.R Nasri & B.N. Remillard (2023). Tests of independence and randomness for arbitrary data using copula-based covariances
y<- SimAR1Poisson(c(5,0.2),100) out <- EstDepSerialMoebius(y,4,4)
y<- SimAR1Poisson(c(5,0.2),100) out <- EstDepSerialMoebius(y,4,4)
This function computes the quantile of seven cdf used in the simulatuons of Nasri (2022).
Finv(u, k)
Finv(u, k)
u |
Vector of probabilities |
k |
Marginal distribution: [1] Bernoulli(0.8), [2] Poisson(6), [3] Negative binomial with r = 1.5, p = 0.2, [4] Zero-inflated Poisson (10) with w = 0.1 and P(6.67) otherwise, [5] Zero-inflated Gaussian, [6] Discretized Gaussian, [7] Discrete Pareto(1) |
x |
Vector of quantiles |
Bouchra R. Nasri January 2021
B.R Nasri (2022). Tests of serial dependence for arbitrary distributions
x = Finv(runif(100),2)
x = Finv(runif(100),2)
Horseshoe Crab Data from Table 3.2 of Agresti(2007). This data set consists of five variables, three of which are categorical, measured on 173 female crabs, each having a male attached in her nest.
data(horseshoecrabs)
data(horseshoecrabs)
Data frame with 173 rows and 5 variables:
X1: Color of the female (1: light medium, 2: medium, 3: dark medium, 4: dark)
X2: Spine condition (1: both good. 2: one worn or broken, 3: both worn or broken)
X3: Carapace width (cm)
X4: Number of satellites, i.e., other males around the female
X5: Weight (kg)
Agresti, A. (2007). An Introduction to Categorical data analysis, John Wiley & Sons, Wiley Series in Probability and Statistics, 2nd edition.
data(horseshoecrabs) x =data.matrix(horseshoecrabs) out = TestIndCopula(x,trunc.level=5,graph=TRUE)
data(horseshoecrabs) x =data.matrix(horseshoecrabs) out = TestIndCopula(x,trunc.level=5,graph=TRUE)
240 body movement measurements of a fetal lamb at consecutive 5 second intervals.
data(lamb)
data(lamb)
Count data.
Leroux B, Putterman M (1992). Maximum Penalized Likelihood estimation for independent and Markov-dependent Mixture models.Biometrics, 48, 545–558.
data(lamb) plot(lamb)
data(lamb) plot(lamb)
This function uses a AIC/BIC type criterion to select p based on the data.
select_p(X, p0 = 2, d = 5, q = 2.4, lambda = 0.25)
select_p(X, p0 = 2, d = 5, q = 2.4, lambda = 0.25)
X |
Time series |
p0 |
Minimum value of p (default is 2) |
d |
Maximum value of p (default is 5) |
q |
Constant for selecting between AIC and BIC type penalty (default is 2.4) |
lambda |
Penalty term (default is 0.25); small values lead to p=d, large value lead to p=p0 |
p |
Selected value of p |
B.R Nasri (2021). Tests of serial dependence for arbitrary distributions
X <- SimAR1Poisson(c(5,0.2),100) out <- select_p(X)
X <- SimAR1Poisson(c(5,0.2),100) out <- select_p(X)
Conditionally on the past, X[t] is Poisson with lambda[t] = a+bX[t-1]
SimAR1Poisson(param, n)
SimAR1Poisson(param, n)
param |
Param[1] = a>0, param[2] = b, 0<=b <1 (for stationarity) |
n |
Length of the series. |
X |
Simulated series |
data <- SimAR1Poisson(c(5,0.4),500)
data <- SimAR1Poisson(c(5,0.4),500)
This function simulates a Markovian time series (p-Markov for the Farlie-Gumbel-Morgenstern copula) with uniform margins using a copula family for the joint distribution of U[t], U[t-1].
SimCopulaSeries(family, n, tau = 0, param = NULL)
SimCopulaSeries(family, n, tau = 0, param = NULL)
family |
"ind", "tent", "gaussian", "t" , "clayton", "fgm", "frank", "gumbel", joe" , "plackett" |
n |
length of the time series |
tau |
Kendall's tau of the copula family |
param |
extra copula parameter: for "fgm", param is the dimension of the copula; for "t", param = nu |
U |
Simulated time series |
Bouchra R. Nasri January 2021
B.R Nasri (2022). Tests of serial dependence for arbitrary distributions
U = SimCopulaSeries("fgm",100,0.2, 3) # for the FGM, |tau|<= 2/9
U = SimCopulaSeries("fgm",100,0.2, 3) # for the FGM, |tau|<= 2/9
This function computes Cramer-von Mises statistics and their combination for a tests of independence between random variables with arbitrary distributions. The P-values are computed using Gaussian multipliers.
TestIndCopula( x, trunc.level = 2, B = 1000, par = FALSE, ncores = 2, graph = FALSE )
TestIndCopula( x, trunc.level = 2, B = 1000, par = FALSE, ncores = 2, graph = FALSE )
x |
Data matrix |
trunc.level |
Only subsets of cardinality <= trunc.level (default=2) are considered for the Moebius statistics. |
B |
Number of multipliers samples (default = 1000) |
par |
Set to TRUE if one prefers paraller computing (slower) |
ncores |
Number of cores for parallel computing (default is 2) |
graph |
Set to TRUE if one wants the dependogram of P-values for the Moebius statistics |
stat |
List of Cramer-von Mises statistics cvm, Sn from the multilinear copula, and test combinations Tn and Tn2 (only pairs) |
pvalue |
Approximated P-values for the tests using Gaussian multipliers |
card |
Cardinaly of the subsets for the Moebius statistics |
subsets |
Subsets for the Moebius statistics |
Genest, Neslehova, Remillard & Murphy (2019). Testing for independence in arbitrary distributions
x <- matrix(rnorm(250),ncol=5) out <-TestIndCopula(x)
x <- matrix(rnorm(250),ncol=5) out <-TestIndCopula(x)
This function computes Cramer-von Mises statistics from the multilinear copula and their combination for tests of randomness of p consecutives values X(1), ..., X(p). The p-values are computed using Gaussian multipliers.
TestIndSerCopula( x, p, trunc.level = 2, B = 1000, par = FALSE, ncores = 2, graph = FALSE )
TestIndSerCopula( x, p, trunc.level = 2, B = 1000, par = FALSE, ncores = 2, graph = FALSE )
x |
Time series |
p |
Number of consecutive observations |
trunc.level |
Only subsets of cardinality <= trunc.level (default=2) are considered for the Moebius statistics. |
B |
Number of multipliers samples (default = 1000) |
par |
Set to TRUE if one prefers paraller computing (slower) |
ncores |
Number of cores for parallel computing (default = 2) |
graph |
Set to TRUE if one wants the dependogram of P-values for the Moebius statistics |
stat |
List of Cramer-von Mises statistics cvm, Sn, and test combinations Tn and Tn2 (only pairs) |
pvalue |
Approximated P-values for the tests using Gaussian multipliers |
card |
Cardinaly of the subsets for the Moebius statistics |
subsets |
Subsets for the Moebius statistics |
B.R Nasri (2022). Tests of serial dependence for arbitrary distributions
X <- SimAR1Poisson(c(5,0.2),100) out <- TestIndSerCopula(X,5,3)
X <- SimAR1Poisson(c(5,0.2),100) out <- TestIndSerCopula(X,5,3)
This function computes Cramer-von Mises statistics from the multilinear copula and their combination for a tests of randomness for p consecutives values of random vectors X(1), ..., X(p). The p-values are computed using Gaussian multipliers.
TestIndSerCopulaMulti(x, p, trunc.level = 2, B = 1000, graph = FALSE)
TestIndSerCopulaMulti(x, p, trunc.level = 2, B = 1000, graph = FALSE)
x |
Time series matrix |
p |
Number of consecutive vectors |
trunc.level |
Only subsets of cardinality <= trunc.level (default=2) are considered for the Moebius statistics. |
B |
Number of multipliers samples (default = 1000) |
graph |
Set to TRUE if one wants the dependogram of P-values for the Moebius statistics |
stat |
List of Cramer-von Mises statistics cvm, tilde Sn, and test combinations tilde Tn and tilde Tn2 (only pairs), as defined in Nasri(2022). |
pvalue |
Approximated P-values for the tests using Gaussian multipliers |
B.R Nasri (2022). Tests of serial dependence for arbitrary distributions
data(Y) out <- TestIndSerCopulaMulti(Y,5,5)
data(Y) out <- TestIndSerCopulaMulti(Y,5,5)
Simulated AR(1) Poisson sequence of length n=100 with parameters c(5,0.4).
data(X)
data(X)
Count data.
data(X) acf(X)
data(X) acf(X)
Simulated Bernoulli sequence.
data(Xbin)
data(Xbin)
Count data.
data(Xbin) plot(Xbin)
data(Xbin) plot(Xbin)
Simulated VAR(1) Poisson sequence of length n=100.
data(Y)
data(Y)
Count data.
data(Y) acf(Y)
data(Y) acf(Y)