GoodmanKruskalGamma[v1,v2]
gives the Goodman–Kruskal
coefficient for the vectors v1 and v2.
gives the Goodman–Kruskal
coefficients for the matrix m.
GoodmanKruskalGamma[m1,m2]
gives the Goodman–Kruskal
coefficients for the matrices m1 and m2.
GoodmanKruskalGamma[dist]
gives the
coefficient matrix for the multivariate symbolic distribution dist.
GoodmanKruskalGamma[dist,i,j]
gives the ![]()
coefficient for the multivariate symbolic distribution dist.
GoodmanKruskalGamma
GoodmanKruskalGamma[v1,v2]
gives the Goodman–Kruskal
coefficient for the vectors v1 and v2.
gives the Goodman–Kruskal
coefficients for the matrix m.
GoodmanKruskalGamma[m1,m2]
gives the Goodman–Kruskal
coefficients for the matrices m1 and m2.
GoodmanKruskalGamma[dist]
gives the
coefficient matrix for the multivariate symbolic distribution dist.
GoodmanKruskalGamma[dist,i,j]
gives the ![]()
coefficient for the multivariate symbolic distribution dist.
Details
- GoodmanKruskalGamma[v1,v2] gives the Goodman–Kruskal coefficient
between v1 and v2. - Goodman–Kruskal
is a measure of monotonic association based on the relative order of consecutive elements in the two lists. - Goodman–Kruskal
between
and
is given by
, where
is the number of concordant pairs of observations and
is the number of discordant pairs. - A concordant pair of observations
and
is one such that both
and
or both
and
. A discordant pair of observations is one such that
and
or
and
. - If no ties are present,
is equivalent to KendallTau. - The arguments v1 and v2 can be any real‐valued vectors of equal length.
- For a matrix m with
columns, GoodmanKruskalGamma[m] is a
×
matrix of the
-coefficients between columns of m. - For an
×
matrix m1 and an
×
matrix m2, GoodmanKruskalGamma[m1,m2] is a
×
matrix of the
-coefficients between columns of m1 and columns of m2. - GoodmanKruskalGamma[dist,i,j] gives
where
is equal to Probability[(x1-x2)(y1-y2)>0,{{x1,y1}disti,j,{x2,y2}disti,j}] and
is equal to Probability[(x1-x2)(y1-y2)<0,{{x1,y1}disti,j,{x2,y2}disti,j}] where disti,j is the 
marginal of dist. - GoodmanKruskalGamma[dist] gives a matrix
where the 
entry is given by GoodmanKruskalGamma[dist,i,j].
Examples
open all close allBasic Examples (4)
Goodman–Kruskal
for two vectors:
v1 = {3, -4, 1, 4, 22, 17, -2, 2, 13, -11};
v2 = {-20, -24, 0, 4, 24, 36, -12, -12, 56, -14};GoodmanKruskalGamma[v1, v2]m = RandomVariate[BinormalDistribution[.6], 10^3];GoodmanKruskalGamma[m]//MatrixFormGoodman–Kruskal
for two matrices:
m1 = RandomReal[1, {10^3, 4}];m2 = RandomReal[1, {10^3, 3}];GoodmanKruskalGamma[m1, m2]//MatrixFormCompute the Goodman–Kruskal
for a bivariate distribution:
𝒟 = BinormalDistribution[.5];GoodmanKruskalGamma[𝒟]//MatrixFormGoodmanKruskalGamma[RandomVariate[𝒟, 10^4]]//MatrixFormScope (7)
Data (4)
Exact input yields exact output:
GoodmanKruskalGamma[{1, 2, 3, 1, 4, 6}, {2, 1, 8, 7, 2, 1}]Approximate input yields approximate output:
GoodmanKruskalGamma[{1.1, 2, 3, 1, 4, 6}, {2, 1, 8, 7, 2, 1}]GoodmanKruskalGamma[N[{1, 3, 5, 6, 6}, 30], N[{2, -1, 6, 8, 9}, 30]]GoodmanKruskalGamma[RandomReal[1, 10 ^ 4], RandomReal[1, 10 ^ 4]]SparseArray data can be used:
GoodmanKruskalGamma[SparseArray[{{2, 2} -> 1, {5, 3} -> 2, {10, 1} -> 3}]]//MatrixFormDistributions and Processes (3)
Goodman–Kruskal
matrix for a continuous multivariate distribution:
GoodmanKruskalGamma[BinormalDistribution[.3]]//MatrixFormGoodmanKruskalGamma[BinormalDistribution[0.3], 2, 1]Goodman–Kruskal
matrix for derived distributions:
GoodmanKruskalGamma[ProductDistribution[ExponentialDistribution[1], ExponentialDistribution[2]]]//MatrixForm𝒟 = CopulaDistribution[{"FGM", 2 / 3}, {UniformDistribution[{0, 1}], UniformDistribution[{0, 1}]}];GoodmanKruskalGamma[𝒟]//MatrixForm𝒟 = HistogramDistribution[RandomVariate[BinormalDistribution[.75], 10 ^ 2]];GoodmanKruskalGamma[𝒟]//MatrixFormGoodmanKruskalGamma[BinormalDistribution[.75]]//MatrixFormGoodman–Kruskal
matrix for a random process at times
and
:
GoodmanKruskalGamma[WienerProcess[][{0.2, 0.3}]]//MatrixFormApplications (3)
Goodman–Kruskal
is typically used to detect linear dependence between two vectors:
{v11, v21} = Transpose[RandomVariate[BinormalDistribution[.99], 1000]];
{v12, v22} = Transpose[RandomVariate[BinormalDistribution[0], 1000]];The absolute magnitude of
tends to 1 given strong linear dependence:
GoodmanKruskalGamma[v11, v21]The value tends to 0 for linearly independent vectors:
GoodmanKruskalGamma[v12, v22]Goodman–Kruskal
measures linear association:
data = BlockRandom[SeedRandom[1];Table[RandomVariate[BinormalDistribution[i], 1000], {i, {-.99, -.75, -.25, -.5, 0., .25, .5, .75, .99}}]];Grid[Partition[Table[ListPlot[i, PlotStyle -> Directive[PointSize[Tiny]],
FrameTicks -> None, Frame -> True, Axes -> None, PlotLabel -> Row[{"ρ : ", GoodmanKruskalGamma[i][[1, 2]]}]], {i, data}],
3]]Goodman–Kruskal
can only detect monotonic dependency:
uni = RandomReal[{-3, 3}, 1000];f[x_] := {{x, -Sqrt[Abs[x]] + RandomReal[.5]}, {x, .25x^2 + RandomReal[.5]}, {x, -Sinc[x] + RandomReal[.5]}, {Cos[x], Sin[x] + RandomReal[.5]}}data = f /@ uni;Table[ListPlot[data[[All, i]], Frame -> True, Axes -> None, PlotLabel -> Row[{"ρ : ", GoodmanKruskalGamma[data[[All, i]]][[1, 2]]}], PlotStyle -> Directive[PointSize[Tiny]], FrameTicks -> None], {i, 4}]HoeffdingD can be used to detect other dependence structures:
Table[HoeffdingD[data[[All, i]]][[1, 2]], {i, 4}]Properties & Relations (5)
Goodman–Kruskal
ranges from -1 to 1 for negative and positive association, respectively:
d = RandomReal[1, 100];GoodmanKruskalGamma[d, d]GoodmanKruskalGamma[d, -d]The Goodman-Kruskal
matrix is symmetric:
gkg = GoodmanKruskalGamma[RandomVariate[BinormalDistribution[1 / 3], 10 ^ 3]];SymmetricMatrixQ[gkg]The diagonal elements of the Goodman–Kruskal
matrix are 1:
data = RandomInteger[{-3, 3}, {100, 15}];Diagonal[GoodmanKruskalGamma[data]]In the absence of ties, Goodman–Kruskal
is equivalent to KendallTau:
data = BlockRandom[SeedRandom[1];Table[RandomVariate[BinormalDistribution[i], 2000], {i, {-.99, -.75, -.25, -.5, 0., .25, .5, .75, .99}}]];Table[ KendallTau[i][[1, 2]] == GoodmanKruskalGamma[i][[1, 2]], {i, data}]Goodman–Kruskal
handles ties differently:
data2 = Round[BlockRandom[SeedRandom[1];Table[RandomVariate[BinormalDistribution[i], 2000], {i, {-.99, -.75, -.25, -.5, 0., .25, .5, .75, .99}}]], 1];N[Table[(KendallTau[i][[1, 2]]/GoodmanKruskalGamma[i][[1, 2]]), {i, data2}]]Goodman–Kruskal
for a bivariate distribution:
𝒟 = CopulaDistribution[{"AMH", 2 / 3}, {UniformDistribution[{0, 1}], UniformDistribution[{0, 1}]}];gkg = GoodmanKruskalGamma[𝒟, 1, 2]pc = Probability[(Subscript[x, 1] - Subscript[x, 2])(Subscript[y, 1] - Subscript[y, 2]) > 0, {{Subscript[x, 1], Subscript[y, 1]}𝒟, {Subscript[x, 2], Subscript[y, 2]}𝒟}];
pd = Probability[(Subscript[x, 1] - Subscript[x, 2])(Subscript[y, 1] - Subscript[y, 2]) < 0, {{Subscript[x, 1], Subscript[y, 1]}𝒟, {Subscript[x, 2], Subscript[y, 2]}𝒟}];(pc - pd/pc + pd)gkg - %//FullSimplifyRelated Guides
History
Text
Wolfram Research (2012), GoodmanKruskalGamma, Wolfram Language function, https://reference.wolfram.com/language/ref/GoodmanKruskalGamma.html.
CMS
Wolfram Language. 2012. "GoodmanKruskalGamma." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/GoodmanKruskalGamma.html.
APA
Wolfram Language. (2012). GoodmanKruskalGamma. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/GoodmanKruskalGamma.html
BibTeX
@misc{reference.wolfram_2026_goodmankruskalgamma, author="Wolfram Research", title="{GoodmanKruskalGamma}", year="2012", howpublished="\url{https://reference.wolfram.com/language/ref/GoodmanKruskalGamma.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_goodmankruskalgamma, organization={Wolfram Research}, title={GoodmanKruskalGamma}, year={2012}, url={https://reference.wolfram.com/language/ref/GoodmanKruskalGamma.html}, note=[Accessed: 12-June-2026]}