Learn R Programming

XICOR (version 0.3.3)

xicor: Compute the cross rank increment correlation coefficient xi.

Description

This function computes the xi coefficient between two vectors x and y, possibly all coefficients for a matrix. If only one coefficient is computed it can be used to test independence using a Monte Carlo permutation test or through an asymptotic approximation test.

Usage

xicor(
  x,
  y = NULL,
  pvalue = FALSE,
  ties = TRUE,
  method = "asymptotic",
  nperm = 1000,
  factor = FALSE
)

Value

In the case pvalue=FALSE, function returns the value of the xi coefficient, if the input is a matrix, a matrix of coefficients is returned. In the case pvalue=TRUE is chosen, the function returns a list:

sd

The standard deviation.

pval

The test p-value.

Arguments

x

Vector of numeric values in the first coordinate.

y

Vector of numeric values in the second coordinate.

pvalue

Whether or not to return the p-value of rejecting independence, if TRUE the function also returns the standard deviation of xi.

ties

Do we need to handle ties? If ties=TRUE the algorithm assumes that the data has ties and employs the more elaborated theory for calculating s.d. and P-value. Otherwise, it uses the simpler theory. There is no harm in putting ties = TRUE even if there are no ties.

method

If method = "asymptotic" the function returns P-values computed by the asymptotic theory. If method = "permutation", a permutation test with nperm permutations is employed to estimate the P-value. Usually, there is no need for the permutation test. The asymptotic theory is good enough.

nperm

In the case of a permutation test, nperm is the number of permutations to do.

factor

Whether to transform integers into factors, the default is to leave them alone.

Author

Sourav Chatterjee, Susan Holmes

References

Chatterjee, S. (2020) <arXiv:1909.10140>.

See Also

dcov

Examples

Run this code

##---- Should be DIRECTLY executable !! ----
library("psychTools")
data(peas)
# Visualize       the peas data
library(ggplot2)
ggplot(peas,aes(parent,child)) +
geom_count() + scale_radius(range=c(0,5)) +
       xlim(c(13.5,24))+ylim(c(13.5,24))+       coord_fixed() +
       theme(legend.position="bottom")
# Compute one of the coefficients
xicor(peas$parent,peas$child,pvalue=TRUE)
xicor(peas$child,peas$parent)
# Compute all the coefficients
xicor(peas)

Run the code above in your browser using DataLab