cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
New to using JMP? Hit the ground running with the Early User Edition of Discovery Summit. Register now, free of charge.
Register for our Discovery Summit 2024 conference, Oct. 21-24, where you’ll learn, connect, and be inspired.
Choose Language Hide Translation Bar
r30363
Level I

how to make cumulative probability plots in JMP?

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

r30363_0-1658152068599.png

 

 

29 REPLIES 29
jthi
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
hogi
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

hogi_0-1677100587366.png

 

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(
				gbb << add variable(
					{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 )} ) ) ) ) );

updates: 
- 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.

 

hogi
Level XI

Re: how to make cumulative probability plots in JMP?

-

Mauro_Gerber
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"
- GLaDOS
hogi
Level XI

Re: how to make cumulative probability plots in JMP?

Thanks, I removed it.

Thomas1
Level V

Re: how to make cumulative probability plots in JMP?

Thanks for this great JSL code.

hogi
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:

hogi_0-1678125330242.png

 

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?

 

 

hogi_2-1678125597146.png

 

 

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" ) )
	)
);

 

hogi
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:
Summary Statistics: add Cumulative Probability 

 

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.

Mauro_Gerber
Level IV

Re: how to make cumulative probability plots in JMP?

@hogi :

Mauro_Gerber_0-1679466946825.png

 

"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"
- GLaDOS
hogi
Level XI

Re: how to make cumulative probability plots in JMP?

@Mauro Thanks a lot for the Kudo - an also for the other 3.
With 4 Kudos this feature should be kind of save to appear in a future Jmp version