Subscribe Bookmark RSS Feed

Getting Values for shortest half range

vince_faller

Super User

Joined:

Mar 17, 2015

Is there a way to get the actual values from the shortest half vis in the outlier box plot?

1 ACCEPTED SOLUTION

Accepted Solutions
markbailey

Staff

Joined:

Jun 23, 2011

Solution

Tonya's solution is clever and right to the point. The rest of the script is actually not that bad. The variable jrn contains a string representation of the Distriution platform (not just the Outlier Box Plot). So let's use string functions to suss out the desired ends of the red bracket. We find argument with Contains() and we extract the bits with a succession of calls to Word():

 

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

dist = dt << Distribution( Y( :weight ) );

rpt = dist << Report;

jrn = rpt[FrameBox(2)] << Get Journal;

pos = Contains( Upper Case( jrn ), "ADJACENTS" );

adj = Word( 2, Sub Str( jrn, pos ), "()" );

lo = Num( Word( 3, adj, "," ) );
hi = Num( Word( 4, adj, "," ) );
8 REPLIES
txnelson

Super User

Joined:

Jun 22, 2012

I don't see anyway to retrieve such information. I tried a real simpleton method of looking at the ranges of 50% of the data from lowest to highest, to see if that would match up, but it failed. It would be a nice enhancement, to be able to "<< get shorterhalf values".

I would pass it on to support@jmp.com
Jim
tonya_mauldin0

Joined:

Jan 21, 2015

Yes, but it is not particularly easy.  These values present themselves as the last two numbers in the adjacents portion of the journal.  First you need to get the journal for a box plot.

 

dt=Open("$SAMPLE_DATA/Big Class.jmp");
obj=dt<<Distribution(Y(:height));
rpt=obj<<report;
jrn=rpt[FrameBox(2)]<<get journal;

Next, you will have to parse jrn for adjacents.  Perhaps someone with more JSL experience can help you with that if you do not already know how to do that.  I'm not familiar with the ins and outs of parsing.

 

markbailey

Staff

Joined:

Jun 23, 2011

Solution

Tonya's solution is clever and right to the point. The rest of the script is actually not that bad. The variable jrn contains a string representation of the Distriution platform (not just the Outlier Box Plot). So let's use string functions to suss out the desired ends of the red bracket. We find argument with Contains() and we extract the bits with a succession of calls to Word():

 

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

dist = dt << Distribution( Y( :weight ) );

rpt = dist << Report;

jrn = rpt[FrameBox(2)] << Get Journal;

pos = Contains( Upper Case( jrn ), "ADJACENTS" );

adj = Word( 2, Sub Str( jrn, pos ), "()" );

lo = Num( Word( 3, adj, "," ) );
hi = Num( Word( 4, adj, "," ) );
tonya_mauldin0

Joined:

Jan 21, 2015

Thanks for finishing my script, Mark!  I've never been the most efficient with the character functions.

vince_faller

Super User

Joined:

Mar 17, 2015

Hi Tonya, 

Any reason you could think of that I'd get a value of 

 

adjacents(0,0,0,0)

 

?

 

It's definitely not 0-0 as the shortest range.  Sorry but I can't post the actual data.  I'll see if I'm allowed to anonymize it.  

vince_faller

Super User

Joined:

Mar 17, 2015

Hi Tonya, 

Any reason you could think of that I'd get a value of 

 

adjacents(0,0,0,0)

 

?

 

It's definitely not 0-0 as the shortest range.  Sorry but I can't post the actual data.  I'll see if I'm allowed to anonymize it.  

 

*Edit* Nevermind.  For some reason my adjacents went to Framebox(1) and all the framebox(2)  were 0s.  

John_Powell_JMP

Joined:

May 30, 2014

This isn't really an answer, but maybe useful in some cases. If you just wanted to see the shortest half values, you could save as Interactive HTML and hover over the red bracket.

Interactive HTML Box Plot Shortest Half ValuesInteractive HTML Box Plot Shortest Half Values

When viewing in a mobile browser, just tap the red bracket.

 

ms

Super User

Joined:

Jun 23, 2011

Thanks for sharing the <<Get Journal idea. Really clever and new to me. 

Here's an attempt to get the limits by raw calculation. In my limited testing it compares well with the Journal numbers. It seems to handle missing values and ties as expected (but I may have missed something).

// Function for calculating the lower and upper limits of
// Shortest Half Range of a numeric column.

shorth = Function({col}, {M, n, d, i = 0},
    M = col << get values;
    M = Sort Ascending(M[Loc Nonmissing(M)]);
    n = N Row(M) / 2 + Mod(N Row(M), 2);
    d = Loc Min(J(1, n, M[(i++) + n] - M[i]));
    lo = M[d];
    hi = M[d + n - 1];
);

// Test
dt = Open("$SAMPLE_DATA/Big Class.jmp");
shorth(Column(dt, "weight"));
Show(lo, hi);