cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
jbolinger
Level II

Creating a flexible Bivariate script with n Conditions (example given)

I am trying to write a script to automate the creation of a Bivariate graph. Below is an example of my data:

 

jmp script 1.jpg

 

I created the Bivariate output I wanted using the point-and-click method:

  • assigning column OD to the Y response, column Assigned Cal for the X response, and column Lot for the By role
  • right-click on the red triangle, click Group By, selecting column Condition
  • right-click on the red triangle, click Fit Special, selecting 2 Quadratic from the dropdown and unchecking Centered Polynomial

and the resulting graph is what I want: 

 

JMP script 3.jpg

 

The resulting script from making this via the point-and-click method is as follows:

 

platform = Data Table (dt3) <<
Bivariate(
	Y( :OD ),
	X( :"Assigned Cal"n ),
	Fit Where(
		:Condition == "Vendor 4",
		Fit Special(
			Degree( 2 ),
			Centered Polynomial( 0 ),
			{Line Color( {212, 73, 88} )}
		)
	),
	Fit Where(
		:Condition == "Vendor 1",
		Fit Special(
			Degree( 2 ),
			Centered Polynomial( 0 ),
			{Line Color( {61, 174, 70} )}
		)
	),
	Fit Where(
		:Condition == "Vendor 2",
		Fit Special(
			Degree( 2 ),
			Centered Polynomial( 0 ),
			{Line Color( {66, 112, 221} )}
		)
	),
	Fit Where(
		:Condition == "Vendor 3",
		Fit Special(
			Degree( 2 ),
			Centered Polynomial( 0 ),
			{Line Color( {204, 121, 41} )}
		)
	),
	By( :Lot )
);

 

This is well and good, but in my example I had 4 unique Condition values (Vendor 1, Vendor 2, Vendor 3, Vendor 4). When my coworkers use this script, their data may have a different number of conditions (2 or more) and their condition names may be different. In the script above, the 4 unique Condition values are referred to specifically, colors are assigned specifically, etc.

 

So my question is: how can I write a general script for this process that will do the same actions for n unique Condition values with various names?

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Creating a flexible Bivariate script with n Conditions (example given)

You need to use the << Group By( column ) message with the Bivariate object before fitting the chosen model:

 

platform = Data Table (dt3) <<
Bivariate(
	Y( :OD ),
	X( :"Assigned Cal"n ),
	By( :Lot )
);


platform << Group By( :Condition );

platform << Fit Special(
	Degree( 2 ),
	Centered Polynomial( 0 )
);

 

View solution in original post

2 REPLIES 2

Re: Creating a flexible Bivariate script with n Conditions (example given)

You need to use the << Group By( column ) message with the Bivariate object before fitting the chosen model:

 

platform = Data Table (dt3) <<
Bivariate(
	Y( :OD ),
	X( :"Assigned Cal"n ),
	By( :Lot )
);


platform << Group By( :Condition );

platform << Fit Special(
	Degree( 2 ),
	Centered Polynomial( 0 )
);

 

jbolinger
Level II

Re: Creating a flexible Bivariate script with n Conditions (example given)

I figured the solution might be as simple as this, but I just lacked experience with how things like Group By() and Fit Special() work as direct messages. This solved my problem, thanks!