cancel
Showing results for
Show  only  | Search instead for
Did you mean:
Choose Language Hide Translation Bar
Level I

## how to make cumulative probability plots in JMP?

How can I make cumulative probability plot like the one below? Appreciate your help.

27 REPLIES 27
Super User

## Re: how to make cumulative probability plots in JMP?

These two topics might be helpful:

You might be able to use similar methods with Variables (search Graph Builder Box from Scripting Index).

-Jarmo
Level XI

## Re: how to make cumulative probability plots in JMP?

"remove variable" - just in front of my eyes, but I did not see it.

Many thanks

``````Names Default To Here( 1 );

dt = Current Data Table();

updatePlot2 = Function( {},
If( Length( clb << get selected ) == 0 | Length( clb2 << get selected ) == 0,
Print( "value missing" ),
gbr = Report( gb );
gbb = gbr[Graph Builder Box( 1 )];
var = (clb << get selected)[1];
groupByvar = (clb2 << get selected)[1];

allVariables = (gbb << get variables);
For Each( {var, idx}, Reverse( allVariables ),
gbb << remove variable( {var[1] , Role(  Arg( var[2] ) )} )
);

gbb << add variable( {Column( var ), Role( "X" )} );

Eval(
Eval Expr(
{Transform Column(
"Cumulative Probability[1=100%]",
Formula(
Col Rank( Expr( Name Expr( As Column( var ) ) ), Expr( Name Expr( As Column( groupByvar ) ) ),Excluded() ) / (
Col Number( Expr( Name Expr( As Column( var ) ) ), Expr( Name Expr( As Column( groupByvar ) ) ),Excluded() ) + 1)
)
), Role( "Y" )}
)
)
);

gbb << add variable( {Column( groupByvar ) , Role( "Overlay" )} ) ;
// SendToReport( Dispatch( {}, "Cumulative Probability[1=100%]", ScaleBox, {Scale( "Normal Probability" ), Format( "Best", 12 )} ) )
yAxis = ((gb << xpath( "//ScaleBox" ))[2]);
yAxis << {Scale( "Normal Probability" ), Format( "Best", 12 ), Title};

gb << getXML();

)
);

gbWindow = New Window( "Grouped Cumulative Probability",
hlb = H List Box(
V List Box(
Panel Box( "Value", clb = Col List Box( all, <<Set Data Type( "numeric" ), max selected( 1 ), updatePlot2() ) ),
Panel Box( "group by", clb2 = Col List Box( all, max selected( 1 ), updatePlot2() ) )
),
gb = dt << Graph Builder(
Size( 724, 560 ),
Show Control Panel( 0 ),
Elements( Points( X, Y, Legend( 7 ) ), Smoother( X, Y, Legend( 8 ), Method( "Savitzky-Golay" ), Lambda( 2 ) ) ),
SendToReport( Dispatch( {}, "Cumulative Probability[1=100%]", ScaleBox, {Scale( "Normal Probability" ), Format( "Best", 12 )} ) )
)
)
);``````

- remove & add variable (Y) deletes the normal probability setting on this axis
->  send the normal probability   command again

- new problem: when running the "transform column" a second time and more often, jmp adds a counter to the name on the y axis: `Cumulative Probability[1=100%] XX `-> Y axis no longer accessible by its original name
-> get the y axis title via xPath

- Excluded() added in the Col... functions to force jmp to ignore excluded() rows in the calculation.

Level XI

## Re: how to make cumulative probability plots in JMP?

Ouch!

I just detected the Cumulative Percent item in the Summary settings:

This way it gets much easier to generate a grouped CDF Plot - even with the possibility to use a column switcher.

edit: unfortunately, this code is wrong - see below

``````Names Default To Here( 1 );
verbose = 1;

dt = Current Data Table();

myCols = {};

ex = New Window( "Modal Dialog example",
"Modal",
V List Box(
Lineup Box( N Col( 2 ),
Panel Box( "", fcs = Filter Col Selector() ),
Panel Box( "",
Lineup Box( N Col( 2 ),
Button Box( "variables", variableColsLB << append( fcs << get selected ) ),
variableColsLB = Col List Box(Continuous, width( 200 ), min items( 1 ), nlines( 10 ) ),
Button Box( "group by", groupColLB << append( fcs << get selected ) ),
groupColLB = Col List Box( Nominal, width( 200 ), max items( 1 ), min items( 1 ), nlines( 1 ) )
)
)
),
H List Box(
Button Box( "OK",
For Each( {col, idx}, variableColsLB << get items(), Insert Into( myCols, Name Expr( As Column( dt, col ) ) ) );
groupColName = (groupColLB << get items)[1];
groupCol = Name Expr( As Column( dt, groupColName ) );
),
Button Box( "cancel" )
)
)
);

If(
Not( ex["button"] == 1 ), Stop(),
N Items( myCols ) == 0,
Stop()

);

col1 = myCols[1];

Eval(
Substitute(
Expr(
dt << Graph Builder(
Show Control Panel( 0 ),
Show Title( 0 ),
Size( 500, 300 ),
Variables( X( __col1__ ), Y( __col1__ ),Overlay( __groupCol__ ) ),
Elements( Points( X, Y, Summary Statistic( "Cumulative Percent" ) ) ),
Column Switcher( __col1__, __myCols__ ),
SendToReport(
Dispatch( {}, "Graph Builder", OutlineBox, {Set Title( "Cumulative Distribution Plot" ), Image Export Display( Normal )} )
)
)
),
Expr( __col1__ ), Name Expr( col1 ),
Expr( __myCols__ ), Name Expr( myCols ),
Expr( __groupCol__ ), Name Expr( groupCol ),

)
);``````

Level IV

## Re: how to make cumulative probability plots in JMP?

``//librecall:storeRoles( "CDF", verbose );``

I had to mute the librecall function since I get an error in JMP17. But it seems it works without it just fine.

Can we mark this as solved @r30363 ?

"I thought about our dilemma, and I came up with a solution that I honestly think works out best for one of both of us"
Level XI

## Re: how to make cumulative probability plots in JMP?

Thanks, I removed it.

Level V

## Re: how to make cumulative probability plots in JMP?

Thanks for this great JSL code.

Level XI

## Re: how to make cumulative probability plots in JMP?

Ouch -  sorry, unfortunately, the code doesn't do what it should do.

Cumulative Percent sounded like Cumulative Probability [%] , but unfortunately, it doesn't sum ONES and dive by N, it sums the individual values and divides by the sum of all values:

If the values are "similar", it's a quick hack to get something similar to CDF, but e.g. if the values start from 0 - or are even negative, the plot differs significantly from a CDF.

So close - but too far to fix it, right?

``````dt = Open( "\$SAMPLE_DATA/Airline Delays.jmp" );
dt << Graph Builder(
Variables( X( :Arrival Delay ), Y( :Arrival Delay ), Overlay( :Airline ) ),
Elements(
Points( X, Y, Legend( 6 ), Summary Statistic( "Cumulative Percent" ) )
)
);``````

Level XI

## Re: how to make cumulative probability plots in JMP?

I posted a wish to add Cumulative Probability as an additional option for summary Statistics in Graph Builder:

So, perhaps in Jmp18 it will be THAT EASY to generate a grouped Cumulative Probability Plot in Graph Builder.

The huge advantage compared to https://community.jmp.com/t5/Discussions/how-to-make-cumulative-probability-plots-in-JMP/m-p/607570/... :It would be compatible with the Column Switcher Feature of Graph Builder. No need to generate a GUI around the plot.

Level IV

## Re: how to make cumulative probability plots in JMP?

"I thought about our dilemma, and I came up with a solution that I honestly think works out best for one of both of us"