xicor | R Documentation |
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.
xicor(
x,
y = NULL,
pvalue = FALSE,
ties = TRUE,
method = "asymptotic",
nperm = 1000,
factor = FALSE
)
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, |
factor |
Whether to transform integers into factors, the default is to leave them alone. |
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:
The value of the xi coefficient.
The standard deviation.
The test p-value.
Dataset peas no longer available in psych, we are now using psychTools.
This version does not use a seed as argument, if reproducibility is an issue, set a seed before calling the function.
Sourav Chatterjee, Susan Holmes
Chatterjee, S. (2020) <arXiv:1909.10140>.
dcov
##---- 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.