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-225482%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%EF%BC%9A%E6%89%BE%E5%88%B0%E5%8C%85%E5%90%ABY%E7%9A%84%E6%9F%90%E4%B8%AA%E9%83%A8%E5%88%86%E7%9A%84X%E8%8C%83%E5%9B%B4%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-225482%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E6%82%A8%E5%8F%AF%E4%BB%A5%E5%B0%9D%E8%AF%95%E5%8C%85%E6%8B%AC%E7%9B%B4%E6%96%B9%E5%9B%BE%E8%BE%B9%E6%A1%86%E5%B9%B6%E7%AA%81%E5%87%BA%E6%98%BE%E7%A4%BAY%E5%88%86%E5%B8%83%E7%9A%84%E9%83%A8%E5%88%86%20-%20%E5%BA%94%E7%AA%81%E5%87%BA%E6%98%BE%E7%A4%BAX%E5%80%BC%E3%80%82%26nbsp%3B%20%E7%84%B6%E5%90%8E%EF%BC%8C%E5%A6%82%E6%9E%9C%E8%A6%81%E6%A3%80%E6%9F%A5%E8%BF%99%E4%BA%9B%EF%BC%8C%E5%8F%AF%E4%BB%A5%E5%9C%A8%E6%95%B0%E6%8D%AE%E9%9B%86%E7%9A%84%E5%88%97%E4%B8%AD%E5%91%BD%E5%90%8D%E8%AF%A5%E9%80%89%E6%8B%A9%EF%BC%88%E4%BE%8B%E5%A6%82%EF%BC%8C%E5%85%B4%E8%B6%A3%E7%82%B9%EF%BC%89%E4%BB%A5%E8%BF%9B%E8%A1%8C%E8%BF%9B%E4%B8%80%E6%AD%A5%E5%88%86%E6%9E%90%E3%80%82%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-225519%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%EF%BC%9A%E6%89%BE%E5%88%B0%E5%8C%85%E5%90%ABY%E7%9A%84%E6%9F%90%E4%B8%AA%E9%83%A8%E5%88%86%E7%9A%84X%E8%8C%83%E5%9B%B4%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-225519%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E4%BD%A0%E5%A5%BD%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F15961%22%20target%3D%22_blank%22%3E%20%40NSadeghi%20%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%E8%AF%B7%E6%9F%A5%E7%9C%8B%E6%AD%A4%E8%84%9A%E6%9C%AC%EF%BC%8C%E5%A6%82%E6%9E%9C%E6%9C%89%E7%94%A8%EF%BC%8C%E8%AF%B7%E5%91%8A%E7%9F%A5%E6%88%91%E4%BB%AC%E3%80%82%3C%2FP%3E%0A%3CP%3E%E4%B9%9F%E8%AE%B8%E5%85%B6%E4%BB%96%E4%BA%BA%E6%9C%89%E6%9B%B4%E4%BC%98%E9%9B%85%E7%9A%84%E6%96%B9%E5%BC%8F%E6%9D%A5%E5%81%9A%E8%BF%99%E4%BB%B6%E4%BA%8B%E3%80%82%E6%88%91%E4%B9%9F%E6%83%B3%E7%9F%A5%E9%81%93%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0A%0Adt%20%3D%20Open(%20%22%24SAMPLE_DATA%2FBig%20Class.jmp%22%20)%3B%0A%0A%2F%2F%20this%20is%20just%20in%20case%20you%20want%20to%20bring%20the%20data%20back%20to%20original%20row%20order%20later.%0Arowcol%20%3D%20New%20Column(%22Row%22%2C%20Numeric%2C%20%22Continuous%22%2C%20Format(%22Best%22%2C%2012)%2C%20Formula(Row()))%3B%0Adt%20%26lt%3B%26lt%3B%20run%20formulas()%3B%0Arowcol%20%26lt%3B%26lt%3B%20suppress%20eval(%20true%20)%3B%0A%0A%2F%2F%20now%20we%20start%20working%0Adt%20%26lt%3B%26lt%3B%20Sort(%20By(%20%3Aheight%20)%2C%20Order(%20Ascending%20)%2C%20replace%20table%20)%3B%0A%0A%2F%2F%20here%20is%20where%20we%20define%20the%20share%20of%20included%20range%20(0.6)%0Adifcol%20%3D%20New%20Column(%22dif%22%2C%20Numeric%2C%20%22Continuous%22%2C%20Format(%22Best%22%2C%2012)%2C%20Formula(Abs(%3Aheight%20-%20Lag(%3Aheight%2C%20-(N%20Rows()%20*%200.6)))))%3B%0Adt%20%26lt%3B%26lt%3B%20run%20formulas()%3B%0Adifcol%20%26lt%3B%26lt%3B%20suppress%20eval(%20true%20)%3B%0A%0Astart%20%20%3D%20(dt%26lt%3B%3CGET%20rows%3D%22%22%20where%3D%22%22%3E%3D%20start%2C%20row()%26lt%3B%3Dend)%2C1%20%2C0%20%20))%3B%0A%0A%2F%2F%20make%20graphs%20for%20observations%20in%20the%20range%20only.%0ABivariate(%20Y(%20%3Aheight%20)%2C%20X(%20%3Aweight%20)%2C%20Where(%20%3Ainrange%20%3D%3D%201%20)%20)%3B%0A%0AGraph%20Builder(%0A%20Size(%20542%2C%20448%20)%2C%0A%20Show%20Control%20Panel(%200%20)%2C%0A%20Variables(%20X(%20%3Aweight%20)%2C%20Y(%20%3Aheight%20)%20)%2C%20Where(%20%3Ainrange%20%3D%3D%201%20)%2C%0A%20Elements(%20Points(%20X%2C%20Y%2C%20Legend(%203%20)%20)%2C%20Smoother(%20X%2C%20Y%2C%20Legend(%204%20)%20)%20)%0A)%3B%3C%2FGET%3E%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-225520%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%EF%BC%9A%E6%89%BE%E5%88%B0%E5%8C%85%E5%90%ABY%E7%9A%84%E6%9F%90%E4%B8%AA%E9%83%A8%E5%88%86%E7%9A%84X%E8%8C%83%E5%9B%B4%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-225520%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E6%82%A8%E5%8F%AF%E4%BB%A5%E6%9F%A5%E6%89%BE%EF%BC%8C%E9%80%89%E6%8B%A9%E5%92%8C%E5%AD%90%E9%9B%86%E5%8C%85%E5%90%AB%EF%BC%88%E4%B8%AD%E9%97%B4%EF%BC%8960%EF%BC%85Y%E5%80%BC%E7%9A%84%E8%A1%8C%EF%BC%8C%E7%84%B6%E5%90%8E%E6%A3%80%E6%9F%A5%E5%85%B3%E8%81%94X%E5%80%BC%E7%9A%84%E5%88%86%E5%B8%83%E3%80%82%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20to%20Here(%201%20)%3B%0A%0Adt%201%20%3D%20Open(%20%22%24SAMPLE_DATA%2FBig%20Class.jmp%22%20)%3B%0A%0Abiv%20%3D%20dt%201%20%26lt%3B%26lt%3B%20Bivariate(%20Y(%20%3Aweight%20)%2C%20X(%20%3Aheight%20)%20)%3B%0A%0Alo%20%3D%20Col%20Quantile(%20%3Aweight%2C%200.2%20)%3B%0Ahi%20%3D%20Col%20Quantile(%20%3Aweight%2C%200.8%20)%3B%0A%0Adt%201%20%26lt%3B%26lt%3B%20Select%20Where(%20lo%20%26lt%3B%3D%20%3Aweight%20%26lt%3B%3D%20hi%20)%3B%0A%0Adt%202%20%3D%20dt%201%20%26lt%3B%26lt%3B%20Subset(%0A%20Selected%20Rows(%201%20)%2C%0A%20Selected%20columns%20only(%200%20)%0A)%3B%0A%0Adist%20%3D%20dt%202%20%26lt%3B%26lt%3B%20Distribution(%20Y(%20%3Aheight%20)%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-225474%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E6%89%BE%E5%88%B0%E5%8C%85%E5%90%ABY%E7%9A%84%E6%9F%90%E4%B8%AA%E9%83%A8%E5%88%86%E7%9A%84X%E8%8C%83%E5%9B%B4%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-225474%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E5%97%A8%EF%BC%8C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%E6%88%91%E7%9A%84%E9%97%AE%E9%A2%98%E5%8F%AF%E8%83%BD%E5%BE%88%E7%AE%80%E5%8D%95%EF%BC%8C%E4%BD%86%E6%88%91%E4%BC%BC%E4%B9%8E%E6%97%A0%E6%B3%95%E5%BC%84%E6%98%8E%E7%99%BD%E3%80%82%3C%2FP%3E%0A%3CP%3E%E6%88%91%E6%9C%89%E4%B8%80%E4%B8%AAY%E5%88%97%EF%BC%8C%E6%88%91%E5%B7%B2%E5%B0%86%E5%85%B6%E7%BB%98%E5%88%B6%E4%B8%BA%E4%B8%8E%E5%88%97X%E7%9B%B8%E6%AF%94%EF%BC%8C%E5%AE%83%E7%9C%8B%E8%B5%B7%E6%9D%A5%E5%83%8F%E9%99%84%E5%8A%A0%E5%9B%BE%E5%83%8F%E3%80%82%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%E6%88%91%E6%83%B3%E5%9C%A8X%E4%B8%AD%E6%89%BE%E5%88%B0%E5%AE%83%E4%BA%A7%E7%94%9F%EF%BC%88%E6%88%96%E5%8C%85%E6%8B%AC%EF%BC%8960%EF%BC%85Y%E7%82%B9%E7%9A%84%E8%8C%83%E5%9B%B4%E3%80%82%E6%B2%A1%E6%9C%89%E4%B8%8E2%E5%88%97%E7%9B%B8%E5%85%B3%E7%9A%84%E5%AE%9A%E4%B9%89%E5%85%AC%E5%BC%8F%E3%80%82%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%E6%9C%89%E4%BB%BB%E4%BD%95%E6%83%B3%E6%B3%95%E5%90%97%EF%BC%9F%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Fit%20Y%20by%20X.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F19280i5CBE87A114D09FAF%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Fit%20Y%20by%20X.jpg%22%20alt%3D%22Fit%20Y%20by%20X.jpg%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
NSadeghi
Level I

Finding the X range that will include a certain portion of the Y

Hi,

 

My problem is probably very simple but I just don't seem to be able to figure it out.

I have a column Y that I have plotted it vs column X and it looks something like the attached image. 

I want to find the range in X where it yields (or includes) 60% of Y points. There is no defind formula that relates the 2 columns.

 

Any ideas?

Fit Y by X.jpg

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
ron_horne
Super User (Alumni)

Re: Finding the X range that will include a certain portion of the Y

Hi @NSadeghi 

please have a look at this script and let us know if it is useful.

perhaps someone else has a more elegant way of doing this. i would also like to know

Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

// this is just in case you want to bring the data back to original row order later.
rowcol = New Column("Row", Numeric, "Continuous", Format("Best", 12), Formula(Row()));
dt << run formulas();
rowcol << suppress eval( true );

// now we start working
dt << Sort( By( :height ), Order( Ascending ), replace table );

// here is where we define the share of included range (0.6)
difcol = New Column("dif", Numeric, "Continuous", Format("Best", 12), Formula(Abs(:height - Lag(:height, -(N Rows() * 0.6)))));
dt << run formulas();
difcol << suppress eval( true );

start  = (dt<<get rows where(Col minimum (:dif)==:dif))[1];
// here we also mantion the share of included range (0.6)
end = start + nrows(dt)*0.6 -1;

// new binary column for in or out the range
dt << New Column("inrange", Numeric, "Ordinal");
for each row (:inrange = if (and (row() >= start, row()<=end),1 ,0  ));

// make graphs for observations in the range only.
Bivariate( Y( :height ), X( :weight ), Where( :inrange == 1 ) );

Graph Builder(
	Size( 542, 448 ),
	Show Control Panel( 0 ),
	Variables( X( :weight ), Y( :height ) ), Where( :inrange == 1 ),
	Elements( Points( X, Y, Legend( 3 ) ), Smoother( X, Y, Legend( 4 ) ) )
);

View solution in original post

Re: Finding the X range that will include a certain portion of the Y

You find, select, and subset the rows containing the (middle) 60% of the Y values, and then examine the distribution of the associated X values.

 

Names Default to Here( 1 );

dt 1 = Open( "$SAMPLE_DATA/Big Class.jmp" );

biv = dt 1 << Bivariate( Y( :weight ), X( :height ) );

lo = Col Quantile( :weight, 0.2 );
hi = Col Quantile( :weight, 0.8 );

dt 1 << Select Where( lo <= :weight <= hi );

dt 2 = dt 1 << Subset(
	Selected Rows( 1 ),
	Selected columns only( 0 )
);

dist = dt 2 << Distribution( Y( :height ) );

View solution in original post

3 REPLIES 3
dale_lehman
Level VII

Re: Finding the X range that will include a certain portion of the Y

You could try including histogram borders and highlighting the section of the Y distribution - the X values should be highlighted.  Then, if you want to examine these, you can name that selection in a column of the data set (e.g., points of interest) for further analysis.

ron_horne
Super User (Alumni)

Re: Finding the X range that will include a certain portion of the Y

Hi @NSadeghi 

please have a look at this script and let us know if it is useful.

perhaps someone else has a more elegant way of doing this. i would also like to know

Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

// this is just in case you want to bring the data back to original row order later.
rowcol = New Column("Row", Numeric, "Continuous", Format("Best", 12), Formula(Row()));
dt << run formulas();
rowcol << suppress eval( true );

// now we start working
dt << Sort( By( :height ), Order( Ascending ), replace table );

// here is where we define the share of included range (0.6)
difcol = New Column("dif", Numeric, "Continuous", Format("Best", 12), Formula(Abs(:height - Lag(:height, -(N Rows() * 0.6)))));
dt << run formulas();
difcol << suppress eval( true );

start  = (dt<<get rows where(Col minimum (:dif)==:dif))[1];
// here we also mantion the share of included range (0.6)
end = start + nrows(dt)*0.6 -1;

// new binary column for in or out the range
dt << New Column("inrange", Numeric, "Ordinal");
for each row (:inrange = if (and (row() >= start, row()<=end),1 ,0  ));

// make graphs for observations in the range only.
Bivariate( Y( :height ), X( :weight ), Where( :inrange == 1 ) );

Graph Builder(
	Size( 542, 448 ),
	Show Control Panel( 0 ),
	Variables( X( :weight ), Y( :height ) ), Where( :inrange == 1 ),
	Elements( Points( X, Y, Legend( 3 ) ), Smoother( X, Y, Legend( 4 ) ) )
);

Re: Finding the X range that will include a certain portion of the Y

You find, select, and subset the rows containing the (middle) 60% of the Y values, and then examine the distribution of the associated X values.

 

Names Default to Here( 1 );

dt 1 = Open( "$SAMPLE_DATA/Big Class.jmp" );

biv = dt 1 << Bivariate( Y( :weight ), X( :height ) );

lo = Col Quantile( :weight, 0.2 );
hi = Col Quantile( :weight, 0.8 );

dt 1 << Select Where( lo <= :weight <= hi );

dt 2 = dt 1 << Subset(
	Selected Rows( 1 ),
	Selected columns only( 0 )
);

dist = dt 2 << Distribution( Y( :height ) );

Recommended Articles