I used this reference because it was the only one that I found that included the necessary details:
"Marchu, Victor A. A., Francisco A. R. Rojas, and Francisco Louzada,
"The Chi-Plot and Its Asymptotic Confidence Interval for Analyzing Bivariate
Dependence: An Application to the Average Intelligence and Atheism Rates
across Nations Data", Journal of Data Science 10(2012), 711-722."
I wrote this script and verified the equations, but the plots do not look right to me, so I did not go any further.
Names Default to Here( 1 );
// get data columns for Y and X roles
dt = Current Data Table();
If( Is Empty( dt ),
Throw( "No data table open" );
);
dialog = New Window( "Chi-Plot", << Modal,
H List Box(
dt clb = Col List Box( All ),
Line Up Box( N Col( 2 ),
Button Box( "Y",
item = dt clb << Get Selected;
y clb << Append( item );
If( N Items( x clb << Get Items ) > 0,
ok bb << Enable( 1 ),
ok bb << Enable( 0 )
);
),
y clb = Col List Box(
Min Items( 1 ), Max Items( 1 ),
<< Set Analysis Type( Continuous )
),
Button Box( "X",
item = dt clb << Get Selected;
x clb << Append( item );
If( N Items( y clb << Get Items ) > 0,
ok bb << Enable( 1 ),
ok bb << Enable( 0 )
);
),
x clb = Col List Box(),
Button Box( "Remove",
y clb << Remove All;
x clb << Remove All;
ok bb << Enable( 0 );
),
Text Box( "")
)
),
H List Box(
ok bb = Button Box( "OK",
y col = Column( (y clb << Get Items)[1] );
x col = Column( (x clb << Get Items)[1] ),
<< Enable( 0 )
),
Button Box( "Cancel")
)
);
// unload dialog
If( dialog["Button"] == -1,
Throw( "User cancelled" );
);
// utility to user alerts
alert# = Function( { msg },
New Window( "Alert", << Modal,
Text Box(
" " || msg || " ",
<< Justify Text( "center" ),
<< Set Font Size( 12 )
),
Text Box( " " )
);
);
// sample size and scaling
n = N Row( dt );
scale = 1 / (n-1);
// data vectors
y = y col << Get As Matrix;
x = x col << Get As Matrix;
// cumulative indicators
F = G = H = J( n, 1, . );
// chi-plot coordinates
χ = λ = J( n, 1, . );
For Each Row(
If( Not( Excluded( Row State() ) ),
i = Row();
// compute cumulative indicators for current row
F[i] = scale * Summation( j = 1, n, If( j != i, x[j] <= x[i], 0 ) );
G[i] = scale * Summation( j = 1, n, If( j != i, y[j] <= y[i], 0 ) );
H[i] = scale * Summation( j = 1, n, If( j != i, x[j] <= x[i] & y[j] <= y[i], 0 ) );
// computer chi-plot coordinates for current row
χ[i] = (H[i] - (F[i] * G[i])) / Sqrt( F[i] * (1-F[i]) * G[i] * (1-G[i]) );
sign = ((F[i]-0.5) * (G[i]-0.5));
λ[i] = 4 * sign * Maximum( (F[i]-0.5)^2, (G[i]-0.5)^2 );
);
);
// add coordinates to data table
χ col = dt << New Column( "χ", Numeric, Continuous, Values( χ ) );
λ col = dt << New Column( "λ", Numeric, Continuous, Values( λ ) );
// add table script for Chi-Plot
dt << New Script( "Chi-Plot",
Current Data Table() << Graph Builder(
Size( 600, 400 ),
Show Control Panel( 0 ),
Show Legend( 0 ),
Variables( X( :λ ), Y( :χ ) ),
Elements( Points( X, Y, Legend( 3 ) ) ),
SendToReport(
Dispatch(
{},
"λ",
ScaleBox,
{Min( -1 ), Max( 1 ), Inc( 0.2 ), Minor Ticks( 0 )}
),
Dispatch(
{},
"χ",
ScaleBox,
{Min( -1 ), Max( 1 ), Inc( 0.2 ), Minor Ticks( 0 )}
),
Dispatch( {}, "graph title", TextEditBox, {Set Text( "Chi-Plot" )} )
)
);
);
// launch Chi-Plot
gb = dt << Graph Builder(
Size( 600, 400 ),
Show Control Panel( 0 ),
Show Legend( 0 ),
Variables( X( :λ ), Y( :χ ) ),
Elements( Points( X, Y, Legend( 3 ) ) ),
SendToReport(
Dispatch(
{},
"λ",
ScaleBox,
{Min( -1 ), Max( 1 ), Inc( 0.2 ), Minor Ticks( 0 )}
),
Dispatch(
{},
"χ",
ScaleBox,
{Min( -1 ), Max( 1 ), Inc( 0.2 ), Minor Ticks( 0 )}
),
Dispatch( {}, "graph title", TextEditBox, {Set Text( "Chi-Plot" )} )
)
);