Choose Language Hide Translation Bar
Highlighted
ad
ad
Level II

How do I implement using JSL ?

Hi All,

 

How do I implemement the steps as outlined in the excel (attached) using JSL ? I have also attached some JSL script which might be useful to acheive  some of the intermediate steps I am trying to implement using JSL, so you can copy it if it is relevant and useful ?

Bivariate(
	Y( :y1_y2_y3 ),
	X( :x1_x2_x3 ),
	Fit Where(
		:Case == "A",
		Fit Special( yTran( "Log" ), {Line Color( "Dark Green" )} )
	),
	Fit Where(
		:Case == "B",
		Fit Special( yTran( "Log" ), {Line Color( "Medium Dark Red" )} )
	),
	Fit Where(
		:Case == "C",
		Fit Special( yTran( "Log" ), {Line Color( "Black" )} )
	),
	Fit Where(
		:Case == "D",
		Fit Special( yTran( "Log" ), {Line Color( "Magenta" )} )
	),
	Fit Where(
		:Case == "E",
		Fit Special( yTran( "Log" ), {Line Color( "Blue" )} )
	),
	Fit Where(
		:Case == "F",
		Fit Special( yTran( "Log" ), {Line Color( "Medium Dark Cyan" )} )
	),
	SendToReport(
		Dispatch(
			{},
			"1",
			ScaleBox,
			{Min( 2.318802 ), Max( 6.35577464892554 ), Inc( 0.5 ), Minor Ticks( 1 ),
			Add Ref Line( 0.526, "Solid", "Black", "yref_1", 1 ),
			Add Ref Line( 1.21, "Solid", "Black", "yref_2", 1 ),
			Add Ref Line( 2.421, "Solid", "Black", "yref_3", 1 ),
			Label Row( {Show Major Grid( 1 ), Show Minor Grid( 1 )} )}
		),
		Dispatch(
			{},
			"2",
			ScaleBox,
			{Scale( "Log" ), Format( "Scientific", 11, 0 ), Min( 0.0000000003 ),
			Max( 0.00001144934215806 ), Inc( 1 ), Minor Ticks( 1 ),
			Add Ref Line( 0.000000579, "Solid", "Black", "x_ref3", 1 ),
			Add Ref Line( 0.000000053, "Solid", "Black", "x_ref2", 1 ),
			Add Ref Line( 0.0000000075, "Solid", "Black", "xref_1", 1 ),
			Label Row( {Show Major Grid( 1 ), Show Minor Grid( 1 )} )}
		),
		Dispatch(
			{},
			"Bivar Plot",
			FrameBox,
			{DispatchSeg( Line Seg( 1 ), {Line Color( "Dark Green" )} ),
			DispatchSeg( Line Seg( 6 ), {Line Color( "Medium Dark Red" )} ),
			DispatchSeg( Line Seg( 11 ), {Line Color( "Black" )} ),
			DispatchSeg( Line Seg( 16 ), {Line Color( "Magenta" )} ),
			DispatchSeg( Line Seg( 21 ), {Line Color( "Blue" )} ),
			DispatchSeg( Line Seg( 26 ), {Line Color( "Medium Dark Cyan" )} )}
		)
	)
)
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
txnelson
Super User

Re: How do I implement using JSL ?

OK....I should have been clearer.  All of the code that I supplied that creates the data table was put there, just to be able to create an example data table to demonstrate the code.  You can input the data table directly from Excel, or where ever you have your data.  The only real part of the script is needed, once you read in your data, is:

// Create the Median Table
dtSumm = dt << Summary(
	Group( :Case ),
	Median( :x1 ),
	Median( :x2 ),
	Median( :x3 ),
	Median( :y1 ),
	Median( :y2 ),
	Median( :y3 ),
	Freq( "None" ),
	Weight( "None" ),
	statistics column name format( "column" ),
	Link to original data table( 0 )
);
dtStack = dtSumm << Stack(
	columns( :x1, :x2, :x3, :y1, :y2, :y3 ),
	Source Label Column( "Label" ),
	Stacked Data Column( "Data" ),
	Name( "Non-stacked columns" )(Keep( :Case )),
	Number of Series( 2 ),
	Contiguous
);

// Clean Up data table
dtStack << delete columns( {"Label", "Label 2"} );
dtStack:Data << set name( "x1_x2_x3" );
dtStack:Data 2 << set name( "y1_y2_y3" );

Biv = dtStack << Bivariate(
	Y( :y1_y2_y3 ),
	X( :x1_x2_x3 ),
	Fit Where(
		:Case == "A",
		Fit Special( yTran( "Log" ), {Line Color( "Dark Green" )} )
	),
	Fit Where(
		:Case == "B",
		Fit Special( yTran( "Log" ), {Line Color( "Medium Dark Red" )} )
	),
	Fit Where( :Case == "C", Fit Special( yTran( "Log" ), {Line Color( "Black" )} ) ),
	Fit Where(
		:Case == "D",
		Fit Special( yTran( "Log" ), {Line Color( "Magenta" )} )
	),
	Fit Where( :Case == "E", Fit Special( yTran( "Log" ), {Line Color( "Blue" )} ) ),
	Fit Where(
		:Case == "F",
		Fit Special( yTran( "Log" ), {Line Color( "Medium Dark Cyan" )} )
	),
	SendToReport(
		Dispatch(
			{},
			"1",
			ScaleBox,
			{Min( 2.318802 ), Max( 6.35577464892554 ), Inc( 0.5 ), Minor Ticks( 1 ),
			Add Ref Line( 0.526, "Solid", "Black", "yref_1", 1 ),
			Add Ref Line( 1.21, "Solid", "Black", "yref_2", 1 ),
			Add Ref Line( 2.421, "Solid", "Black", "yref_3", 1 ),
			Label Row( {Show Major Grid( 1 ), Show Minor Grid( 1 )} )}
		),
		Dispatch(
			{},
			"2",
			ScaleBox,
			{Scale( "Log" ), Format( "Scientific", 11, 0 ), Min( 0.0000000003 ),
			Max( 0.00001144934215806 ), Inc( 1 ), Minor Ticks( 1 ),
			Add Ref Line( 0.000000579, "Solid", "Black", "x_ref3", 1 ),
			Add Ref Line( 0.000000053, "Solid", "Black", "x_ref2", 1 ),
			Add Ref Line( 0.0000000075, "Solid", "Black", "xref_1", 1 ),
			Label Row( {Show Major Grid( 1 ), Show Minor Grid( 1 )} )}
		),
		Dispatch(
			{},
			"Bivar Plot",
			FrameBox,
			{DispatchSeg( Line Seg( 1 ), {Line Color( "Dark Green" )} ),
			DispatchSeg( Line Seg( 6 ), {Line Color( "Medium Dark Red" )} ),
			DispatchSeg( Line Seg( 11 ), {Line Color( "Black" )} ),
			DispatchSeg( Line Seg( 16 ), {Line Color( "Magenta" )} ),
			DispatchSeg( Line Seg( 21 ), {Line Color( "Blue" )} ),
			DispatchSeg( Line Seg( 26 ), {Line Color( "Medium Dark Cyan" )} )}
		)
	)
);

BTW, what method are you using to enter in the data?  If you are having a problem with that, we can work on that too.

 

Jim

View solution in original post

12 REPLIES 12
Highlighted
txnelson
Super User

Re: How do I implement using JSL ?

Here is a simple script that generates the tables and output you want

x1x2x3.PNG

Names Default To Here( 1 );
//dt = Current Data Table();
dt = New Table( "Example",
	Add Rows( 18 ),
	New Column( "Case",
		Character,
		"Nominal",
		Set Values(
			{"A", "A", "A", "B", "B", "B", "C", "C", "C", "D", "D", "D", "E", "E",
			"E", "F", "F", "F"}
		)
	),
	New Column( "x1",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values(
			[1.61428690437666, 10.1190080125253, 6.73662807021899, 8.01466805846589,
			6.68158041069847, 5.7112128821412, 2.84688009253613, 8.24143884561082,
			7.93797713835799, 7.60500406538651, 6.10376724167353, 7.49901866647003,
			6.75689551558008, 8.47900118679714, 8.31129239105815, 2.25776032554558,
			3.47918899345697, 7.54113635144146]
		)
	),
	New Column( "x2",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values(
			[5.47938474920207, 6.18766439511594, -6.23767012529314, 2.09002457182833,
			4.8113689086524, 7.03651072603935, -3.04550198990374, 11.8452893346908,
			-3.05733149292515, 1.30049361512582, 1.01507442873964, 2.09317649939774,
			7.41286830274582, 7.34393706953047, 6.35773586672512, 6.45581826439945,
			14.9562095399741, 10.0634660675686]
		)
	),
	New Column( "x3",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values(
			[11.2656869903562, 2.97417375436776, 2.7691367152201, 9.75641926280114,
			9.70879299538533, 7.16035571615696, 9.79872763007834, 2.99361815483094,
			7.34989095258795, 11.8347155967071, 13.840944548243, 6.91213509473278,
			12.9829334337807, 4.69016477226892, 6.5541527241742, 10.449257706405,
			8.71860875295487, 2.75703552707507]
		)
	),
	New Column( "y1",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values(
			[0.0000000021187715823, 0.0000000007070458434, 0.0000000021305415897,
			0.000000002187751479, 0.0000000015163549964, 0.0000000006662765716,
			0.0000000013568530851, 0.0000000022185225971, 0.0000000008126367887,
			0.0000000014370349256, 0.0000000025500410724, 0.0000000019674810787,
			-0.0000000005869971784, 1.82706897276242e-10, 0.0000000014877347984,
			6.66831811738687e-11, 0.000000001044052589, 0.0000000019169076496]
		)
	),
	New Column( "y2",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values(
			[0.0000000111634035809, 0.0000000150934383918, 0.0000000092632031811,
			0.0000000014897580792, 0.0000000129447047918, 0.0000000038471184132,
			0.000000020378302554, 0.0000000084939824652, 0.0000000306867238143,
			0.0000000083704926078, -0.0000000019845073029, 0.0000000221987482462,
			-1.12731592825071e-10, 0.0000000341691546291, 0.0000000243189078007,
			0.0000000142112672565, 0.0000000157219085064, 0.0000000163609065787]
		)
	),
	New Column( "y3",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Selected,
		Set Values(
			[0.0000001356080410826, 0.0000003110230604448, 0.0000000731675260394,
			0.0000000683020170167, 0.0000000166660984052, 0.0000001245784167858,
			0.0000001917424143272, 0.0000000592217777822, 0.0000000682651021339,
			0.0000001310868753601, 0.0000000929550618751, 0.0000001752103336127,
			0.0000000988598859477, 0.0000000990272186345, 0.000000121745118966,
			0.0000001243361078368, 0.0000001992144095096, 0.000000090951358824]
		)
	)
);

// Create the Median Table
dtSumm = dt << Summary(
	Group( :Case ),
	Median( :x1 ),
	Median( :x2 ),
	Median( :x3 ),
	Median( :y1 ),
	Median( :y2 ),
	Median( :y3 ),
	Freq( "None" ),
	Weight( "None" ),
	statistics column name format( "column" ),
	Link to original data table( 0 )
);
dtStack = dtSumm << Stack(
	columns( :x1, :x2, :x3, :y1, :y2, :y3 ),
	Source Label Column( "Label" ),
	Stacked Data Column( "Data" ),
	Name( "Non-stacked columns" )(Keep( :Case )),
	Number of Series( 2 ),
	Contiguous
);

// Clean Up data table
dtStack << delete columns( {"Label", "Label 2"} );
dtStack:Data << set name( "x1_x2_x3" );
dtStack:Data 2 << set name( "y1_y2_y3" );

Biv = dtStack << Bivariate(
	Y( :y1_y2_y3 ),
	X( :x1_x2_x3 ),
	Fit Where(
		:Case == "A",
		Fit Special( yTran( "Log" ), {Line Color( "Dark Green" )} )
	),
	Fit Where(
		:Case == "B",
		Fit Special( yTran( "Log" ), {Line Color( "Medium Dark Red" )} )
	),
	Fit Where( :Case == "C", Fit Special( yTran( "Log" ), {Line Color( "Black" )} ) ),
	Fit Where(
		:Case == "D",
		Fit Special( yTran( "Log" ), {Line Color( "Magenta" )} )
	),
	Fit Where( :Case == "E", Fit Special( yTran( "Log" ), {Line Color( "Blue" )} ) ),
	Fit Where(
		:Case == "F",
		Fit Special( yTran( "Log" ), {Line Color( "Medium Dark Cyan" )} )
	),
	SendToReport(
		Dispatch(
			{},
			"1",
			ScaleBox,
			{Min( 2.318802 ), Max( 6.35577464892554 ), Inc( 0.5 ), Minor Ticks( 1 ),
			Add Ref Line( 0.526, "Solid", "Black", "yref_1", 1 ),
			Add Ref Line( 1.21, "Solid", "Black", "yref_2", 1 ),
			Add Ref Line( 2.421, "Solid", "Black", "yref_3", 1 ),
			Label Row( {Show Major Grid( 1 ), Show Minor Grid( 1 )} )}
		),
		Dispatch(
			{},
			"2",
			ScaleBox,
			{Scale( "Log" ), Format( "Scientific", 11, 0 ), Min( 0.0000000003 ),
			Max( 0.00001144934215806 ), Inc( 1 ), Minor Ticks( 1 ),
			Add Ref Line( 0.000000579, "Solid", "Black", "x_ref3", 1 ),
			Add Ref Line( 0.000000053, "Solid", "Black", "x_ref2", 1 ),
			Add Ref Line( 0.0000000075, "Solid", "Black", "xref_1", 1 ),
			Label Row( {Show Major Grid( 1 ), Show Minor Grid( 1 )} )}
		),
		Dispatch(
			{},
			"Bivar Plot",
			FrameBox,
			{DispatchSeg( Line Seg( 1 ), {Line Color( "Dark Green" )} ),
			DispatchSeg( Line Seg( 6 ), {Line Color( "Medium Dark Red" )} ),
			DispatchSeg( Line Seg( 11 ), {Line Color( "Black" )} ),
			DispatchSeg( Line Seg( 16 ), {Line Color( "Magenta" )} ),
			DispatchSeg( Line Seg( 21 ), {Line Color( "Blue" )} ),
			DispatchSeg( Line Seg( 26 ), {Line Color( "Medium Dark Cyan" )} )}
		)
	)
);
Jim
Highlighted
ad
ad
Level II

Re: How do I implement using JSL ?

Hi Jim,

 

Thank you so much for your detailed reply. I appreciate it, let me try it and I will let you know.

 

Regards,
AD

Highlighted
ad
ad
Level II

Re: How do I implement using JSL ?

Hi Jim,

Thank you for your quick solution ! I have a few more questions , if you can please help.

 

I am wondering if this is JSL script will scale up easily for large sets of data.

 

1. It seems you hardcoded the number of instances of each case "A", "B" , ...."F".

 

It is okay to do so if you have 2-3 instances of each case , but what if I have more like 100s of instances each for "A", "B" .."F". Then I have to repeat "A" 100s of times in the code below ?

 

Set Values(

{"A", "A", "A", "B", "B", "B", "C", "C", "C", "D", "D", "D", "E", "E",

"E", "F", "F", "F"}

 

2. You also entered each of the values for the column variables : "x1", "x2" ....""y3" as shown below . Again, I have > 1000 rows of data for each of the variables. Then typing in all the values for each variable looks more cumbersome.

 

New Column( "x1",

 

Numeric,

"Continuous",

Format( "Best", 12 ),

 

Set Values(

[1.61428690437666, 10.1190080125253, 6.73662807021899, 8.01466805846589,

6.68158041069847, 5.7112128821412, 2.84688009253613, 8.24143884561082,

7.93797713835799, 7.60500406538651, 6.10376724167353, 7.49901866647003,

6.75689551558008, 8.47900118679714, 8.31129239105815, 2.25776032554558,

3.47918899345697, 7.54113635144146]

 

Can you please help let me know if there is a less cumbersome way to implement this for larger datasets?

 

Regards,
AD

 

Highlighted
txnelson
Super User

Re: How do I implement using JSL ?

OK....I should have been clearer.  All of the code that I supplied that creates the data table was put there, just to be able to create an example data table to demonstrate the code.  You can input the data table directly from Excel, or where ever you have your data.  The only real part of the script is needed, once you read in your data, is:

// Create the Median Table
dtSumm = dt << Summary(
	Group( :Case ),
	Median( :x1 ),
	Median( :x2 ),
	Median( :x3 ),
	Median( :y1 ),
	Median( :y2 ),
	Median( :y3 ),
	Freq( "None" ),
	Weight( "None" ),
	statistics column name format( "column" ),
	Link to original data table( 0 )
);
dtStack = dtSumm << Stack(
	columns( :x1, :x2, :x3, :y1, :y2, :y3 ),
	Source Label Column( "Label" ),
	Stacked Data Column( "Data" ),
	Name( "Non-stacked columns" )(Keep( :Case )),
	Number of Series( 2 ),
	Contiguous
);

// Clean Up data table
dtStack << delete columns( {"Label", "Label 2"} );
dtStack:Data << set name( "x1_x2_x3" );
dtStack:Data 2 << set name( "y1_y2_y3" );

Biv = dtStack << Bivariate(
	Y( :y1_y2_y3 ),
	X( :x1_x2_x3 ),
	Fit Where(
		:Case == "A",
		Fit Special( yTran( "Log" ), {Line Color( "Dark Green" )} )
	),
	Fit Where(
		:Case == "B",
		Fit Special( yTran( "Log" ), {Line Color( "Medium Dark Red" )} )
	),
	Fit Where( :Case == "C", Fit Special( yTran( "Log" ), {Line Color( "Black" )} ) ),
	Fit Where(
		:Case == "D",
		Fit Special( yTran( "Log" ), {Line Color( "Magenta" )} )
	),
	Fit Where( :Case == "E", Fit Special( yTran( "Log" ), {Line Color( "Blue" )} ) ),
	Fit Where(
		:Case == "F",
		Fit Special( yTran( "Log" ), {Line Color( "Medium Dark Cyan" )} )
	),
	SendToReport(
		Dispatch(
			{},
			"1",
			ScaleBox,
			{Min( 2.318802 ), Max( 6.35577464892554 ), Inc( 0.5 ), Minor Ticks( 1 ),
			Add Ref Line( 0.526, "Solid", "Black", "yref_1", 1 ),
			Add Ref Line( 1.21, "Solid", "Black", "yref_2", 1 ),
			Add Ref Line( 2.421, "Solid", "Black", "yref_3", 1 ),
			Label Row( {Show Major Grid( 1 ), Show Minor Grid( 1 )} )}
		),
		Dispatch(
			{},
			"2",
			ScaleBox,
			{Scale( "Log" ), Format( "Scientific", 11, 0 ), Min( 0.0000000003 ),
			Max( 0.00001144934215806 ), Inc( 1 ), Minor Ticks( 1 ),
			Add Ref Line( 0.000000579, "Solid", "Black", "x_ref3", 1 ),
			Add Ref Line( 0.000000053, "Solid", "Black", "x_ref2", 1 ),
			Add Ref Line( 0.0000000075, "Solid", "Black", "xref_1", 1 ),
			Label Row( {Show Major Grid( 1 ), Show Minor Grid( 1 )} )}
		),
		Dispatch(
			{},
			"Bivar Plot",
			FrameBox,
			{DispatchSeg( Line Seg( 1 ), {Line Color( "Dark Green" )} ),
			DispatchSeg( Line Seg( 6 ), {Line Color( "Medium Dark Red" )} ),
			DispatchSeg( Line Seg( 11 ), {Line Color( "Black" )} ),
			DispatchSeg( Line Seg( 16 ), {Line Color( "Magenta" )} ),
			DispatchSeg( Line Seg( 21 ), {Line Color( "Blue" )} ),
			DispatchSeg( Line Seg( 26 ), {Line Color( "Medium Dark Cyan" )} )}
		)
	)
);

BTW, what method are you using to enter in the data?  If you are having a problem with that, we can work on that too.

 

Jim

View solution in original post

Highlighted
ad
ad
Level II

Re: How do I implement using JSL ?

Hi Jim,

 

Oh! I see....too bad I didn't realize. Thank you so much for explaining this. That sounds great ! I am reading the data in from an Excel file into JMP. Is there a smart way of doing this ?

 

Regards,
Ad

Highlighted
txnelson
Super User

Re: How do I implement using JSL ?

What does your spreadsheet layout look like?  If it is a row and column table.....like a JMP data table, then the syntax is just:

dt = open("<path to your Excel file>");
Jim
Highlighted
ad
ad
Level II

Re: How do I implement using JSL ?

Hi Jim,

 

I have opened my excel file and saved as a JMP worksheet. Then I am using

 

dt = open( "C:\Users\user_name\Documents\filename.jmp" );

Is this format correct ?

 

I think I am not able to get the plot after implementing your code, I need to understand your code better because my data set parameters are a bit different in parameter names etc.

Can you please explain what is "Label" , "Label2" , Data , Data 2 ? Do I need to define them explicitly in my dataset. As of now, they are not defined. I don't see them defined in your dataset tables you created also.

 

dtStack = dtSumm << Stack(

 

columns( :x1, :x2, :x3, :y1, :y2, :y3 ),

Source Label Column( "Label" ),

Stacked Data Column( "Data" ),

Name( "Non-stacked columns" )(Keep( :Case )),

Number of Series( 2 ),

 

Contiguous

);

 

// Clean Up data table

dtStack << delete columns( {"Label", "Label 2"} );

dtStack:Data << set name( "x1_x2_x3" );

dtStack:Data 2 << set name( "y1_y2_y3" );

 

 

 

Regards,
AD

Highlighted
txnelson
Super User

Re: How do I implement using JSL ?

Concerning your Open() function, if your JMP data table is saved in your Documents folder, and is called "filename.jmp" then it is correct.

The code

dtStack = dtSumm << Stack(
 
	columns( :x1, :x2, :x3, :y1, :y2, :y3 ),
	Source Label Column( "Label" ),
	Stacked Data Column( "Data" ),
	Name( "Non-stacked columns" )(Keep( :Case )),
	Number of Series( 2 ), 
 
	Contiguous
);

is just using the Stack Data Table Platform

     Tables==>Stack

You can run it against your data table manually and get the same results as the script.  But basically, there are 2 sets of columns to be stacked, x1, x2, x3, and the same y variants of y1, y2,  y3.  Thus the specifying of the 6 columns in the Columns() specification, and the setting of Number of Series(2).  The Contigous element indicates to split the list in the middle, rather than alternating between x1, y1.....etc.  When you stack set of columns, the measurements are put into a new column named Data.  And the column names are placed into a new column named Label.  Since we are stacking 2 sets of columns, there are columns Data and Data 2, Label and Label 2.

// Clean Up data table
dtStack << delete columns( {"Label", "Label 2"} );
dtStack:Data << set name( "x1_x2_x3" );
dtStack:Data 2 << set name( "y1_y2_y3" );

This code just deletes the Label and Label 2 columns, since we don't need them, and then Data and Data 2 are renamed into more meaningful names.

You can read about the Stack Platform in the Using JMP document

     Help==>Books==>Using JMP 

Jim
Highlighted
ad
ad
Level II

Re: How do I implement using JSL ?

Thanks a lot Jim for your clear explanations. Let me try it out.

 

Regards,
AD

Article Labels

    There are no labels assigned to this post.