public class CorTest
extends java.lang.Object
Three common types of correlation are Pearson, Spearman (for ranked data) and Kendall (for uneven or multiple rankings), and can be selected using the table below.
|
Parametric variables follow normal distribution and linear relationship between x and y) |
|||||||
|
Y |
Pearson correlation |
||||||
|
N |
|
||||||
To deal with measures of association between nominal variables, we can use Chi-square test for independence. For any pair of nominal variables, the data can be displayed as a contingency table, whose rows are labels by the values of one nominal variable, whose columns are labels by the values of the other nominal variable, and whose entries are nonnegative integers giving the number of observed events for each combination of row and column.
| Modifier and Type | Field and Description |
|---|---|
double |
cor
Correlation coefficient
|
double |
df
Degree of freedom
|
double |
pvalue
(two-sided) p-value of test
|
double |
t
test statistic
|
| Modifier and Type | Method and Description |
|---|---|
static CorTest |
chisq(int[][] table)
Given a two-dimensional contingency table in the form of an array of
integers, returns Chi-square test for independence.
|
static CorTest |
kendall(double[] x,
double[] y)
Kendall rank correlation test.
|
static CorTest |
pearson(double[] x,
double[] y)
Pearson correlation coefficient test.
|
static CorTest |
spearman(double[] x,
double[] y)
Spearman rank correlation coefficient test.
|
public double cor
public double df
public double t
public double pvalue
public static CorTest pearson(double[] x, double[] y)
public static CorTest spearman(double[] x, double[] y)
The raw scores are converted to ranks and the differences between the ranks of each observation on the two variables are calculated.
The p-value is calculated by approximation, which is good for n > 10.
public static CorTest kendall(double[] x, double[] y)
public static CorTest chisq(int[][] table)