cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-192508%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E9%80%9A%E8%BF%87%E5%88%86%E7%BB%84%E5%8F%98%E9%87%8F%E5%9C%A8%E5%90%8C%E4%B8%80%E5%9B%BE%E4%B8%8A%E7%BB%98%E5%88%B6%E5%B8%B8%E8%A7%84%E5%92%8C%E5%8F%8D%E5%90%91%20CDF%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-192508%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E4%BD%A0%E5%A5%BD%EF%BC%8C%3C%2FP%3E%3CP%3E%E5%AF%B9%E5%88%86%E5%8F%91%E5%B9%B3%E5%8F%B0%E7%9A%84CDF%E5%9B%BE%E6%9C%89%E7%96%91%E9%97%AE%3C%2FP%3E%3CP%3E%E6%88%91%E6%83%B3%E7%BB%98%E5%88%B6%E4%B8%A4%E4%B8%AA%E5%8F%98%E9%87%8F%E7%9A%84%20CDF%EF%BC%8C%E6%AF%94%E5%A6%82%20Y1%20%E5%92%8C%20Y2%EF%BC%8C%E5%AE%83%E4%BB%AC%E5%9C%A8%E7%9B%B8%E5%90%8C%E7%9A%84%E6%95%B0%E5%80%BC%E8%8C%83%E5%9B%B4%E5%86%85%EF%BC%8C%E4%BD%86%E8%8C%83%E5%9B%B4%E4%B8%8D%E5%90%8C%E3%80%82%20%E4%BE%8B%E5%A6%82%20Y1%20%E4%BB%8E%200-100%EF%BC%8CY2%20%E4%BB%8E%200%20%E5%88%B0%201000%E3%80%82%20%E6%88%91%E6%83%B3%E5%83%8F%E5%B8%B8%E8%A7%84%20CDF%20%E5%9B%BE%E4%B8%80%E6%A0%B7%E7%BB%98%E5%88%B6%20Y1%EF%BC%8C%E5%85%B6%E4%B8%AD%20CumProb%20%E4%BB%8E%200%20%E5%88%B0%201%EF%B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1%EF%BC%9F%3C%2FP%3E%3CP%3E%E6%88%91%E4%BB%8E%E8%8E%B7%E5%BE%97%E6%A6%82%E7%8E%87%E5%88%86%E6%95%B0%E5%BC%80%E5%A7%8B%EF%BC%8C%E5%B9%B6%E4%B8%BA%20Y2%20%E6%B7%BB%E5%8A%A0%E4%B8%80%E5%88%97%201-P(X2%20%26gt%3B%20x)%EF%BC%8C%E4%BD%86%E6%88%91%E5%AF%B9%E5%A6%82%E4%BD%95%E8%8E%B7%E5%BE%97%201-P(X2%26gt%3Bx)%20%E5%92%8C%20P(X1%26lt%3B%3Dx1)%20%E5%87%A0%E4%B9%8E%E4%B8%80%E6%97%A0%E6%89%80%E7%9F%A5X%20%E8%BD%B4%EF%BC%8C%E5%B9%B6%E4%B8%94%E7%BB%95%E7%9D%80%E5%9C%88%E5%AD%90%E8%B7%91%E6%9D%A5%E8%B7%91%E5%8E%BB%EF%BC%8C%E6%88%91%E4%B8%80%E8%88%AC%E5%A6%82%E4%BD%95%E5%A4%84%E7%90%86%E8%BF%99%E4%B8%AA%E9%97%AE%E9%A2%98%E3%80%82%20%E4%BB%BB%E4%BD%95%E6%83%B3%E6%B3%95%E5%92%8C%E6%8C%87%E7%A4%BA%E9%83%BD%E4%BC%9A%E9%9D%9E%E5%B8%B8%E6%9C%89%E5%B8%AE%E5%8A%A9%E3%80%82%20%E6%88%91%E6%9C%89%205%20%E4%B8%AA%E4%B8%8D%E5%90%8C%E7%B1%BB%E5%88%AB%E7%9A%84%E5%88%86%E7%BB%84%E5%8F%98%E9%87%8F%EF%BC%8C%E5%B9%B6%E4%B8%94%E4%B8%8D%E4%BB%8B%E6%84%8F%E6%9C%89%205%20%E4%B8%AA%E4%B8%8D%E5%90%8C%E7%9A%84%E6%AD%A4%E7%B1%BB%20cdf%20%E5%9B%BE%E3%80%82%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-192576%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%E9%80%9A%E8%BF%87%E5%88%86%E7%BB%84%E5%8F%98%E9%87%8F%E5%9C%A8%E5%90%8C%E4%B8%80%E5%9B%BE%E4%B8%8A%E7%BB%98%E5%88%B6%E5%B8%B8%E8%A7%84%E5%92%8C%E5%8F%8D%E5%90%91%20CDF%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-192576%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E6%88%91%E9%9D%9E%E5%B8%B8%E5%96%9C%E6%AC%A2%E6%A0%BC%E9%B2%81%E5%90%89%E4%BA%9A%E7%9A%84%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88%E3%80%82%20%E8%BF%99%E6%98%AF%E4%B8%80%E7%A7%8D%E6%9B%B4%E7%AE%80%E5%8D%95%E4%B8%94%E4%B8%8D%E5%90%8C%E7%9A%84%E6%96%B9%E6%B3%95%EF%BC%9A%E5%9C%A8%E7%BB%84%E5%90%88%E7%BB%98%E5%9B%BE%E4%B9%8B%E5%89%8D%E5%AF%B9%E4%B8%A4%E4%B8%AA%E6%95%B0%E6%8D%AE%E9%9B%86%E8%BF%9B%E8%A1%8C%E5%BD%92%E4%B8%80%E5%8C%96%E3%80%82%20%E5%AE%83%E5%8F%AF%E8%83%BD%E4%B8%8D%E4%BC%9A%E9%82%A3%E4%B9%88%E4%BB%A4%E4%BA%BA%E6%BB%A1%E6%84%8F%E3%80%82%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%E6%88%91%E4%BD%BF%E7%94%A8%E4%BA%86%E4%B8%A4%E4%B8%AA%E5%85%B7%E6%9C%89%E4%B8%8D%E5%90%8C%E5%8F%82%E6%95%B0%E7%9A%84%E6%AD%A3%E6%80%81%E5%88%86%E5%B8%83%E6%9D%A5%E8%AF%B4%E6%98%8E%E8%BF%99%E7%A7%8D%E6%96%B9%E6%B3%95%E3%80%82%20%E6%82%A8%E5%8F%AF%E4%BB%A5%E5%B0%86%E7%94%A8%E4%BA%8E%E6%A0%B7%E6%9C%AC%E6%95%B0%E6%8D%AE%E5%88%86%E5%B8%83%E7%9A%84%E6%8B%9F%E5%90%88%E6%A8%A1%E5%9E%8B%E4%BF%9D%E5%AD%98%E4%B8%BA%E5%88%97%E5%85%AC%E5%BC%8F%EF%BC%8C%E8%80%8C%E4%B8%8D%E6%98%AF%E5%83%8F%E6%88%91%E9%82%A3%E6%A0%B7%E7%BB%84%E6%88%90%E6%95%B0%E6%8D%AE%E3%80%82%20%E8%BF%99%E6%98%AF%E7%BB%93%E6%9E%9C%E5%9B%BE%EF%BC%9A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Screen%20Shot%202019-04-11%20at%206.08.21%20AM.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Screen%20Shot%202019-04-11%20at%206.08.21%20AM.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Screen%20Shot%202019-04-11%20at%206.08.21%20AM.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F16849i7E0E1D941C0E12D8%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Screen%20Shot%202019-04-11%20at%206.08.21%20AM.png%22%20alt%3D%22Screen%20Shot%202019-04-11%20at%206.08.21%20AM.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%E6%88%91%E9%99%84%E4%B8%8A%E4%BA%86%E4%B8%BA%E7%94%9F%E6%88%90%E6%AD%A4%E5%9B%BE%E8%80%8C%E5%88%B6%E4%BD%9C%E7%9A%84%E6%95%B0%E6%8D%AE%E8%A1%A8%E3%80%82%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-192519%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%E9%80%9A%E8%BF%87%E5%88%86%E7%BB%84%E5%8F%98%E9%87%8F%E5%9C%A8%E5%90%8C%E4%B8%80%E5%9B%BE%E4%B8%8A%E7%BB%98%E5%88%B6%E5%B8%B8%E8%A7%84%E5%92%8C%E5%8F%8D%E5%90%91%20CDF%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-192519%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E9%99%84%E4%BB%B6%E6%98%AF%E4%B8%80%E4%B8%AA%E8%84%9A%E6%9C%AC%EF%BC%8C%E6%88%91%E7%9B%B8%E4%BF%A1%E5%AE%83%E5%8F%AF%E4%BB%A5%E6%A8%A1%E6%8B%9F%E6%82%A8%E7%9A%84%E6%95%B0%E6%8D%AE%E8%AE%BE%E7%BD%AE%E5%92%8C%E4%B8%A4%E7%A7%8D%E5%88%9B%E5%BB%BA%E6%82%A8%E6%8F%8F%E8%BF%B0%E7%9A%84%E5%9B%BE%E5%BD%A2%E7%9A%84%E6%96%B9%E6%B3%95%E3%80%82%20%E4%B8%80%E4%B8%AA%E4%BD%BF%E7%94%A8%E6%9C%AA%E5%A0%86%E5%8F%A0%E7%9A%84%E6%95%B0%E6%8D%AE%EF%BC%88%E4%B8%A4%E5%88%97%EF%BC%89%EF%BC%8C%E5%8F%A6%E4%B8%80%E4%B8%AA%E4%BD%BF%E7%94%A8%E5%A0%86%E5%8F%A0%E6%95%B0%E6%8D%AE%E3%80%82%E5%A6%82%E6%9E%9C%E6%82%A8%E6%AD%A3%E5%9C%A8%E5%AF%BB%E6%89%BE%20Y2%20%E7%9A%84%20Inv%20Prob%20%26gt%3B%20Prob%20Y1%20%E7%9A%84%E8%A1%8C%EF%BC%8C%E5%88%99%E6%9C%AA%E5%A0%86%E5%8F%A0%EF%BC%88%E5%8E%9F%E5%A7%8B%EF%BC%89%E6%95%B0%E6%8D%AE%E5%B0%86%E6%9B%B4%E6%98%93%E4%BA%8E%E4%BD%BF%E7%94%A8%E3%80%82%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%E6%B3%A8%E6%84%8F%EF%BC%8CY1%20%E5%92%8C%20Y2%20%E8%A2%AB%E6%A8%A1%E6%8B%9F%E4%B8%BA%E5%9D%87%E5%8C%80%E5%88%86%E5%B8%83%E3%80%82%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20to%20Here(1)%3B%0A%0Adt%20%3D%20New%20Table(%22Demo%20-%20Raw%22%2C%20Add%20rows(1000)%2C%0A%20%20%20%20%20%20%20%20New%20Column(%22Y1%22%2C%20Numeric%2C%20Continuous%2C%20%26lt%3B%3CSET%20each%3D%22%22%20value%3D%22%22%3E%3C%2FSET%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%E8%BF%99%E6%98%AF%E4%B8%A4%E4%B8%AA%E5%9B%BE%E8%A1%A8%EF%BC%9A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20711px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20711px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20711px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F16840i2518B26A359067F8%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20465px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20465px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20465px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F16841i71E6FBDC91419526%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
theseventhhill
Level II

Plot conventional and reverse CDF on same plot by grouping variable

Hello,

Have a question on CDF plots on the distribution platform

I would like to plot the CDF of two variables say Y1 and Y2 which are on the same numerical scale but differ by the range/. For example Y1 from 0-100 and Y2 from 0 to 1000. I want to plot Y1like a regular CDF plot with the CumProb going from 0 to 1 and X1 values increasing from 0 to 100.

For Y2, I want the X2 to be in decreasing order from 1000 to 0 but the cumprob of Y2 runs from 0 to Y increasing in the Y axis direction. 

I want to essentially reverse cdf(Y2) and overplot with cdf(Y1) and plot both on the same cdf plot window. Eventually I want to shade specific areas under the curves based on X1 and X2 values but before that I want to know how I could accomplish this task? 

I started with getting the probability score and adding a column for 1-P(X2 > x) for Y2 but was little stuck on how I could get 1-P(X2>x) and P(X1<=x1) on the same X axis and was running around circles with how I could approach this in general. Any thoughts and pointers would be really helpful. I have 5 different categories of a grouping variable and do not mind having 5 different such cdf plots. 

 

2 REPLIES 2
gzmorgan0
Super User (Alumni)

Re: Plot conventional and reverse CDF on same plot by grouping variable

Attached is a script that I believe simulates your data setup and two methods to create the graph you described. One uses unstacked data ( two columns) and another with stacked data.  If you are looking for rows where the Inv Prob of Y2 > Prob Y1 the unstacked (raw) data would be easier to use.

 

Note, Y1 and Y2 were simulated as uniform distributions.

Names Default to Here(1);

dt = New Table("Demo - Raw", Add rows(1000),
        New Column("Y1", Numeric, Continuous, <<Set Each Value(Random Integer(0,100)) ),
        New Column("Y2", Numeric, Continuous, <<Set Each Value(Random Integer(0,1000)) )    
     );

dist = dt << Distribution(
	Continuous Distribution( Column( :Y1 ) ),
	Continuous Distribution( Column( :Y2 ) )
);

dist << Save(Prob Scores);

dist << close window();

dt << New Column("Inv Prob Y2", numeric, continuous, <<Set Each Value(1-:Prob Y2));


//Using Unstacked data and GraphBuilder
gb = dt << Graph Builder(
	Size( 534, 454 ),
	Show Control Panel( 0 ),
	Variables(
		X( :Y1 ),
		X( :Y2, Position( 1 ) ),
		Y( :Prob Y1 ),
		Y( :Inv Prob Y2, Position( 1 ) )
	),
	Elements(
		Smoother( X( 1 ), Y( 1 ), Legend( 25 ) ),
		Smoother( X( 2 ), Y( 2 ), Legend( 27 ) )
	),
	SendToReport(
		Dispatch(
			{},
			"Y1",
			ScaleBox,
			{Min( -100 ), Max( 1100 ), Inc( 50 ), Minor Ticks( 1 ),
			Label Row( {Show Major Grid( 1 ), Show Minor Grid( 1 )} )}
		),
		Dispatch(
			{},
			"Prob Y1",
			ScaleBox,
			{Min( -0.1 ), Max( 1.1 ), Inc( 0.1 ), Minor Ticks( 1 ),
			Label Row( {Show Major Grid( 1 ), Show Minor Grid( 1 )} )}
		)
	)
);


//Sometimes it is easier to stack the data and use Bivariate instead of GraphBuilder

dtstck = dt << Stack(
	columns( :Y1, :Y2, :Prob Y1, :Inv Prob Y2 ),
	Source Label Column( "Label" ),
	Stacked Data Column( "Data" ),
	Stack By Row( 0 ),
	Number of Series( 2 ),
	Contiguous,
	Output Table Name("Demo - Stacked")
);

dtstck:Data2 << set name("Prob");

//this creates one graph with 2 curves
biv = dtstck << Bivariate(
	Y( :Prob ),
	X( :Data ),
	Group By(:Label),
	Fit Each Value( {Report(0)}),
	SendToReport(
		Dispatch(
			{},
			"1",
			ScaleBox,
			{Min( -50 ), Max( 1050 ), Inc( 50 ), Minor Ticks( 1 ),
			Label Row( {Show Major Grid( 1 ), Show Minor Grid( 1 )} )}
		),
		Dispatch(
			{},
			"2",
			ScaleBox,
			{Label Row( {Show Major Grid( 1 ), Show Minor Grid( 1 )} )}
		),

		Dispatch(
			{},
			"Bivar Plot",
			FrameBox,
			{Row Legend(
				Label,
				Color( 1 ),
				Color Theme( "JMP Default" ),
				Marker( 0 ),
				Marker Theme( "" ),
				Continuous Scale( 0 ),
				Reverse Scale( 0 ),
				Excluded Rows( 0 )
			)}
		)
	)
);

Here are the two graphs:

image.pngimage.png

Re: Plot conventional and reverse CDF on same plot by grouping variable

I like Georgia's solution a lot. Here is a simpler and different approach: normalizing the two data sets before combining the plot. It might not be as satisfying.

 

I used two normal distributions with different parameters to illustrate this approach. You could save the fitted model for a distribution of sample data as a column formula instread of making up the data as I did. Here is the resulting plot:

 

Screen Shot 2019-04-11 at 6.08.21 AM.png

 

I attached the data table that I made to produce this plot.

Recommended Articles