cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
DannyORegan94
Level II

JSL for evaluating tolerance interval USL and LSL after calculation

 Hi,

 

So I want to write a script that will calculate a tolerance interval with 99% coverage, alpha = 0.95, on a column of data.

Once it has done this I want to access/evaluate the USL and LSL to be used for hiding/excluding values that fall outside those limits.

The reason I am doing this is I have two columns of data that I have stacked together, and I want to produce side by side box plots.
But when I produce them there are major outliers in the box plots that cause the axes to be scaled poorly. There are only ever going to be a handful of these major outliers so there is no issue with me just getting rid of them

 

I'm pretty new to JMP so any help is appreciated. If you think there is a better/easier way of achieving this that would also be great.

2 ACCEPTED SOLUTIONS

Accepted Solutions
ian_jmp
Staff

Re: JSL for evaluating tolerance interval USL and LSL after calculation

OK Danny. Sometimes you can get the required values directly, and sometimes you need to access the report layer to get them (try 'Help > Books > Scripting Guide').

 

This code should get you started:

NamesDefaultToHere(1);

// Do the Distribution
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dist = dt << Distribution( Column( :Height ) );

// Add tolerance intervals (search for the latter using 'Help > Scripting Guide')
dist << Tolerance Interval(Alpha( 0.95 ), Proportion( 0.85 ));

// Get the report layer
distRep = dist << Report;

// Dig out the required values (do 'Show Tree Structure' to see how the report is made up)
lt = distRep[NumberColBox(5)] << get;
ut = distRep[NumberColBox(6)] << get;

// Set extreme values to missing
vals = Column(dt, "Height") << getValues;
vals[Loc(vals < lt[1] | vals > ut[1] )] = .;
Column(dt, "Height") << setValues(vals);

View solution in original post

gzmorgan0
Super User (Alumni)

Re: JSL for evaluating tolerance interval USL and LSL after calculation

Ian is faster than I. Below is a script for the stacked data. 

 

As Ian was alluding, you need to learn more JSL for selecting and getting values from tables and reports.  To be prepared for your next script you should read the  Help> Books> Scripting Guide chapters "Scripting Platforms" and "Display Trees". This will help you understand the nested structure of JMP reports and learn the syntax to navigate, reference and get.

 

Note that Ian's script empties values. This script maintains their values them, but excludes them from the analyses. 

Names default to Here(1);

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt_stck = dt << Stack(
	columns( :height, :weight ),
	Source Label Column( "Var" ),
	Stacked Data Column( "Data" )
);
close(dt,NoSave);
obj = Distribution( Column( :Data ), By(:Var) );

//using a lower proportion, .80,  to screen something
obj << Tolerance Interval( Alpha( 0.95 ), Proportion( 0.8 ) ); 
 
tol_dt = report(obj[1])[OutlineBox(2)]["Tolerance Intervals"][TableBox(1)]<<Make Combined Data Table;
tol_dt << set Name("Tolerance Intervals");

for(i=1, i<=nrow(tol_dt), i++,
	str = tol_dt:Var[i];
	vlo = tol_dt:Lower TI[i];
	vhi = tol_dt:Upper TI[i];
	dt_stck << select where(:Var==str & (:Data < vlo | :Data > vhi) ) << hide and exclude(1);
	dt_stck << clear select;
);

nw = New Window("Custom Display",
  VListBox(
   onew = dt_stck << Oneway( Y(:Data), X(:Var)),
   text box(),
   dbb = tol_dt  <<New Data Box()
  )
);
dbb << close side panels;
dbb << set max size(410,240);
nw << journal window;

View solution in original post

7 REPLIES 7
gzmorgan0
Super User (Alumni)

Re: JSL for evaluating tolerance interval USL and LSL after calculation

Are the tolerance limits and spec limits different? 

DannyORegan94
Level II

Re: JSL for evaluating tolerance interval USL and LSL after calculation

No I want to use the tolerance limits as spec limits.

ian_jmp
Staff

Re: JSL for evaluating tolerance interval USL and LSL after calculation

Even if you want to script something it's good to do it by hand once, especially since JMP will often generate code that you can use.

 

With that in mind, take a look here to see how to get the Tolerance Intervals via 'Analyze > Distribution'. Once you have these values, you could, for instance, use 'Rows > Row Selection > Select Where . . .', followed by 'Rows > Delete Rows'.

DannyORegan94
Level II

Re: JSL for evaluating tolerance interval USL and LSL after calculation

Hi Ian, thank you for the reply. I know how to write the script that will generate the distribution report and calculate the tolerance interval. Its the next part that I am stuck on. When I get JMP to generate a script for the tolerance interval this is what it gives me:

 

Distribution(
	Continuous Distribution(
		Column( :Data ),
		Tolerance Interval( Alpha( 0.95 ), Proportion( 0.99 ) )
	)
)

 

So you can see, at this point in my script I do not know my USL and LSL. I need my script to somehow read what the USL/LSL of the tolerance interval that it has just calculated are and then exclude/delete rows accordingly.

ian_jmp
Staff

Re: JSL for evaluating tolerance interval USL and LSL after calculation

OK Danny. Sometimes you can get the required values directly, and sometimes you need to access the report layer to get them (try 'Help > Books > Scripting Guide').

 

This code should get you started:

NamesDefaultToHere(1);

// Do the Distribution
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dist = dt << Distribution( Column( :Height ) );

// Add tolerance intervals (search for the latter using 'Help > Scripting Guide')
dist << Tolerance Interval(Alpha( 0.95 ), Proportion( 0.85 ));

// Get the report layer
distRep = dist << Report;

// Dig out the required values (do 'Show Tree Structure' to see how the report is made up)
lt = distRep[NumberColBox(5)] << get;
ut = distRep[NumberColBox(6)] << get;

// Set extreme values to missing
vals = Column(dt, "Height") << getValues;
vals[Loc(vals < lt[1] | vals > ut[1] )] = .;
Column(dt, "Height") << setValues(vals);
gzmorgan0
Super User (Alumni)

Re: JSL for evaluating tolerance interval USL and LSL after calculation

Ian is faster than I. Below is a script for the stacked data. 

 

As Ian was alluding, you need to learn more JSL for selecting and getting values from tables and reports.  To be prepared for your next script you should read the  Help> Books> Scripting Guide chapters "Scripting Platforms" and "Display Trees". This will help you understand the nested structure of JMP reports and learn the syntax to navigate, reference and get.

 

Note that Ian's script empties values. This script maintains their values them, but excludes them from the analyses. 

Names default to Here(1);

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt_stck = dt << Stack(
	columns( :height, :weight ),
	Source Label Column( "Var" ),
	Stacked Data Column( "Data" )
);
close(dt,NoSave);
obj = Distribution( Column( :Data ), By(:Var) );

//using a lower proportion, .80,  to screen something
obj << Tolerance Interval( Alpha( 0.95 ), Proportion( 0.8 ) ); 
 
tol_dt = report(obj[1])[OutlineBox(2)]["Tolerance Intervals"][TableBox(1)]<<Make Combined Data Table;
tol_dt << set Name("Tolerance Intervals");

for(i=1, i<=nrow(tol_dt), i++,
	str = tol_dt:Var[i];
	vlo = tol_dt:Lower TI[i];
	vhi = tol_dt:Upper TI[i];
	dt_stck << select where(:Var==str & (:Data < vlo | :Data > vhi) ) << hide and exclude(1);
	dt_stck << clear select;
);

nw = New Window("Custom Display",
  VListBox(
   onew = dt_stck << Oneway( Y(:Data), X(:Var)),
   text box(),
   dbb = tol_dt  <<New Data Box()
  )
);
dbb << close side panels;
dbb << set max size(410,240);
nw << journal window;
DannyORegan94
Level II

Re: JSL for evaluating tolerance interval USL and LSL after calculation

Thank you! Very much appreciate the help! Sorry about the delay in accepting the answer, I haven't gone back to work on the script until today.