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%3E%EB%8B%A4%EC%8B%9C%20%3A%20Y%EC%9D%98%20%ED%8A%B9%EC%A0%95%20%EB%B6%80%EB%B6%84%EC%9D%84%20%ED%8F%AC%ED%95%A8%ED%95%98%EB%8A%94%20X%20%EB%B2%94%EC%9C%84%20%EC%B0%BE%EA%B8%B0%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-225482%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%ED%9E%88%EC%8A%A4%ED%86%A0%EA%B7%B8%EB%9E%A8%20%EA%B2%BD%EA%B3%84%EB%A5%BC%20%ED%8F%AC%ED%95%A8%EC%8B%9C%ED%82%A4%EA%B3%A0%20Y%20%EB%B6%84%ED%8F%AC%EC%9D%98%20%EC%84%B9%EC%85%98%EC%9D%84%20%EA%B0%95%EC%A1%B0%20%ED%91%9C%EC%8B%9C%20%ED%95%A0%20%EC%88%98%20%EC%9E%88%EC%8A%B5%EB%8B%88%EB%8B%A4.%20X%20%EA%B0%92%EC%9D%84%20%EA%B0%95%EC%A1%B0%20%ED%91%9C%EC%8B%9C%ED%95%B4%EC%95%BC%ED%95%A9%EB%8B%88%EB%8B%A4.%26nbsp%3B%20%EA%B7%B8%EB%9F%B0%20%EB%8B%A4%EC%9D%8C%EC%9D%B4%EB%A5%BC%20%EA%B2%80%ED%86%A0%ED%95%98%EB%A0%A4%EB%A9%B4%20%EC%B6%94%EA%B0%80%20%EB%B6%84%EC%84%9D%EC%9D%84%20%EC%9C%84%ED%95%B4%20%EB%8D%B0%EC%9D%B4%ED%84%B0%20%EC%84%B8%ED%8A%B8%EC%9D%98%20%EC%97%B4%20(%EC%98%88%20%3A%20%EA%B4%80%EC%8B%AC%20%EC%A7%80%EC%A0%90)%EC%97%90%EC%84%9C%20%ED%95%B4%EB%8B%B9%20%EC%84%A0%ED%83%9D%EC%9D%98%20%EC%9D%B4%EB%A6%84%EC%9D%84%20%EC%A7%80%EC%A0%95%ED%95%A0%20%EC%88%98%20%EC%9E%88%EC%8A%B5%EB%8B%88%EB%8B%A4.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-225519%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%EB%8B%A4%EC%8B%9C%20%3A%20Y%EC%9D%98%20%ED%8A%B9%EC%A0%95%20%EB%B6%80%EB%B6%84%EC%9D%84%20%ED%8F%AC%ED%95%A8%ED%95%98%EB%8A%94%20X%20%EB%B2%94%EC%9C%84%20%EC%B0%BE%EA%B8%B0%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-225519%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%EC%95%88%EB%85%95%ED%95%98%EC%84%B8%EC%9A%94%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F15961%22%20target%3D%22_blank%22%3E%20NS%20%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%EC%9D%B4%20%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8%EB%A5%BC%20%EC%82%B4%ED%8E%B4%EB%B3%B4%EA%B3%A0%20%EC%9C%A0%EC%9A%A9%ED%95%9C%20%EC%A7%80%20%EC%95%8C%EB%A0%A4%EC%A3%BC%EC%8B%AD%EC%8B%9C%EC%98%A4.%3C%2FP%3E%0A%3CP%3E%EB%8B%A4%EB%A5%B8%20%EC%82%AC%EB%9E%8C%EC%9D%B4%20%EB%8D%94%20%EC%9A%B0%EC%95%84%ED%95%9C%20%EB%B0%A9%EB%B2%95%EC%9C%BC%EB%A1%9C%20%EC%9D%B4%EA%B2%83%EC%9D%84%20%ED%95%A0%20%EC%88%98%20%EC%9E%88%EC%8A%B5%EB%8B%88%EB%8B%A4.%20%EB%82%98%EB%8F%84%20%EC%95%8C%EA%B3%A0%20%EC%8B%B6%EB%8B%A4%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%3E%EB%8B%A4%EC%8B%9C%20%3A%20Y%EC%9D%98%20%ED%8A%B9%EC%A0%95%20%EB%B6%80%EB%B6%84%EC%9D%84%20%ED%8F%AC%ED%95%A8%ED%95%98%EB%8A%94%20X%20%EB%B2%94%EC%9C%84%20%EC%B0%BE%EA%B8%B0%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-225520%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EY%20%EA%B0%92%EC%9D%98%20(%EC%A4%91%EA%B0%84)%2060%20%25%EB%A5%BC%20%ED%8F%AC%ED%95%A8%ED%95%98%EB%8A%94%20%ED%96%89%EC%9D%84%20%EC%B0%BE%EC%95%84%EC%84%9C%20%EC%84%A0%ED%83%9D%ED%95%98%EA%B3%A0%20%EB%B6%80%EB%B6%84%20%EC%A7%91%ED%95%A9%EC%9D%84%20%EC%B0%BE%EC%9D%80%20%EB%8B%A4%EC%9D%8C%20%EA%B4%80%EB%A0%A8%EB%90%9C%20X%20%EA%B0%92%EC%9D%98%20%EB%B6%84%ED%8F%AC%EB%A5%BC%20%EA%B2%80%EC%82%AC%ED%95%A9%EB%8B%88%EB%8B%A4.%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%3EY%EC%9D%98%20%ED%8A%B9%EC%A0%95%20%EB%B6%80%EB%B6%84%EC%9D%84%20%ED%8F%AC%ED%95%A8%20%ED%95%A0%20X%20%EB%B2%94%EC%9C%84%20%EC%B0%BE%EA%B8%B0%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-225474%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%EC%95%88%EB%85%95%ED%95%98%EC%84%B8%EC%9A%94%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%EB%82%B4%20%EB%AC%B8%EC%A0%9C%EB%8A%94%20%EC%95%84%EB%A7%88%EB%8F%84%20%EB%A7%A4%EC%9A%B0%20%EA%B0%84%EB%8B%A8%ED%95%98%EC%A7%80%EB%A7%8C%20%EC%95%8C%EC%95%84%EB%82%BC%20%EC%88%98%EC%97%86%EB%8A%94%20%EA%B2%83%20%EA%B0%99%EC%8A%B5%EB%8B%88%EB%8B%A4.%3C%2FP%3E%0A%3CP%3EX%20%EC%97%B4%EA%B3%BC%20X%20%EC%97%B4%EC%9D%84%20%ED%94%8C%EB%A1%9C%ED%8C%85%20%ED%95%9C%20Y%20%EC%97%B4%EC%9D%B4%20%EC%9E%88%EC%9C%BC%EB%A9%B0%20%EC%B2%A8%EB%B6%80%20%EB%90%9C%20%EC%9D%B4%EB%AF%B8%EC%A7%80%EC%99%80%20%EB%B9%84%EC%8A%B7%ED%95%A9%EB%8B%88%EB%8B%A4.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EX%EC%97%90%EC%84%9C%20Y%20%ED%8F%AC%EC%9D%B8%ED%8A%B8%EC%9D%98%2060%20%25%EB%A5%BC%20%EC%82%B0%EC%B6%9C%20(%EB%98%90%EB%8A%94%20%ED%8F%AC%ED%95%A8)%ED%95%98%EB%8A%94%20%EB%B2%94%EC%9C%84%EB%A5%BC%20%EC%B0%BE%EA%B3%A0%20%EC%8B%B6%EC%8A%B5%EB%8B%88%EB%8B%A4.%20%EB%91%90%20%EC%97%B4%EA%B3%BC%20%EA%B4%80%EB%A0%A8%EB%90%9C%20%EB%AA%85%ED%99%95%ED%95%9C%20%EA%B3%B5%EC%8B%9D%EC%9D%80%20%EC%97%86%EC%8A%B5%EB%8B%88%EB%8B%A4.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%EC%96%B4%EB%96%A4%20%EC%95%84%EC%9D%B4%EB%94%94%EC%96%B4%3F%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