Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

- JMP User Community
- :
- Discussions
- :
- Getting Values for shortest half range

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Nov 22, 2016 12:08 PM
(12806 views)

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

Vince Faller - Predictum

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Created:
Nov 23, 2016 5:18 AM
| Last Modified: Nov 23, 2016 5:20 AM
(16104 views)
| Posted in reply to message from tonya_mauldin0 11-23-2016

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

Learn it once, use it forever!

9 REPLIES 9

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Getting Values for shortest half range

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

I would pass it on to support@jmp.com

Jim

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Getting Values for shortest half range

Created:
Nov 23, 2016 4:41 AM
| Last Modified: Nov 23, 2016 5:19 AM
(12764 views)
| Posted in reply to message from vince_faller 11-22-2016

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.

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Created:
Nov 23, 2016 5:18 AM
| Last Modified: Nov 23, 2016 5:20 AM
(16105 views)
| Posted in reply to message from tonya_mauldin0 11-23-2016

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

Learn it once, use it forever!

Highlighted
##

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Getting Values for shortest half range

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Getting Values for shortest half range

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 - Predictum

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Getting Values for shortest half range

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.

Vince Faller - Predictum

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Getting Values for shortest half range

Created:
Nov 23, 2016 6:10 AM
| Last Modified: Nov 23, 2016 6:12 AM
(12738 views)
| Posted in reply to message from vince_faller 11-22-2016

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.

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

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Getting Values for shortest half range

Created:
Nov 23, 2016 4:51 PM
| Last Modified: Nov 23, 2016 4:53 PM
(12686 views)
| Posted in reply to message from vince_faller 11-22-2016

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

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Getting Values for shortest half range

a broader version of this question was asked later https://community.jmp.com/t5/Discussions/Finding-the-X-range-that-will-include-a-certain-portion-of-...

my solution is as follows. could anyone chack if it is robust? thank you.

```
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
// this is just in case wewant 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( :weight ), Order( Ascending ), replace table );
// here is where we define the share of included range (0.5)
difcol = New Column("dif", Numeric, "Continuous", Format("Best", 12), Formula(Abs(:weight - Lag(:weight, -(N Rows() * 0.5)))));
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.5)
end = start + nrows(dt)*0.5 -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 ));
```

Article Labels

There are no labels assigned to this post.