Title: | Association Measurement Through Sliced Independence Test (SIT) |
---|---|
Description: | Computes the sit coefficient between two vectors x and y, possibly all paired coefficients for a matrix. The reference for the methods implemented here is Zhang, Yilin, Canyi Chen, and Liping Zhu. 2022. "Sliced Independence Test." Statistica Sinica. <doi:10.5705/ss.202021.0203>. This package incorporates the Galton peas example. |
Authors: | Canyi Chen [aut, cre] |
Maintainer: | Canyi Chen <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.1 |
Built: | 2025-02-14 05:42:25 UTC |
Source: | https://github.com/canyi-chen/sit |
Compute the block-wise sum of a vector.
blocksum(r, c)
blocksum(r, c)
r |
An integer vector |
c |
The number of observations in each block |
The function returns the block sum of the vector.
This function computes the sit coefficient between two vectors x and y.
calculateSIT(x, y, c = 2)
calculateSIT(x, y, c = 2)
x |
Vector of numeric values in the first coordinate. |
y |
Vector of numeric values in the second coordinate. |
c |
The number of observations in each slice. |
The function returns the value of the sit coefficient.
Auxiliary function with no checks for NA, etc.
Yilin Zhang, Canyi Chen & Liping Zhu
Zhang Y., Chen C., & Zhu L. (2021). Sliced Independence Test. Statistica Sinica. https://doi.org/10.5705/ss.202021.0203.
sitcor
# Compute one of the coefficients library("psychTools") data(peas) calculateSIT(peas$parent,peas$child) calculateSIT(peas$child,peas$parent)
# Compute one of the coefficients library("psychTools") data(peas) calculateSIT(peas$parent,peas$child) calculateSIT(peas$child,peas$parent)
This function computes the sit coefficient between two vectors x and y, possibly all paired coefficients for a matrix.
sitcor( x, y = NULL, c = 2, pvalue = FALSE, ties = FALSE, method = "asymptotic", nperm = 199, factor = FALSE )
sitcor( x, y = NULL, c = 2, pvalue = FALSE, ties = FALSE, method = "asymptotic", nperm = 199, factor = FALSE )
x |
Vector of numeric values in the first coordinate. |
y |
Vector of numeric values in the second coordinate. |
c |
The number of observations in each slice. |
pvalue |
Whether or not to return the p-value of rejecting independence, if TRUE the function also returns the standard deviation of sit. |
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 (not available in the presence of ties). 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 sit 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 sit coefficient.
The standard deviation.
The test p-value.
Yilin Zhang, Canyi Chen & Liping Zhu
Zhang Y., Chen C., & Zhu L. (2022). Sliced Independence Test. Statistica Sinica. https://doi.org/10.5705/ss.202021.0203.
##---- 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 sitcor(peas$parent,peas$child, c = 4, pvalue=TRUE) sitcor(peas$child,peas$parent, c = 4) # Compute all the coefficients sitcor(peas, c = 4)
##---- 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 sitcor(peas$parent,peas$child, c = 4, pvalue=TRUE) sitcor(peas$child,peas$parent, c = 4) # Compute all the coefficients sitcor(peas, c = 4)