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

Extracting outputs after maximizing desirability functions

I am running regression models (JMP15) on a dataset "by-group" - i.e. generating 100+ regression models from the same data table. Then I maximize desirability for all these groups. I would like to extract the variable values corresponding to the "maximized desirability" for each of the 100+ models (the circled values in picture below). Any suggestions on how to do that (either JSL or using the GUI are okay)?

 WipulJ_0-1717196082378.png

I can do it in a tedious way (Ctrl-Prediction Profiler -> Factor Settings -> Remember Settings saves the settings for each case as "Remembered Settings", which I can then extract with Ctrl-Make Combined Data Table. However this requires me to hit "enter" 100+ times corresponding to each by-group!).

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Extracting outputs after maximizing desirability functions

For Each() function was not introduced until JMP 16.  Hence the code needs to be changed to a For() loop methodology.

For( i=1,i<=nitems(fm), i++,

Here is the JSL modified to use the For() function, and to also read in the optimized values for the response variables.  I tested the code in JMP 15

Names Default To Here( 1 );
dt = 
// Open Data Table: Tiretread.jmp
// → Data Table( "Tiretread" )
Open( "$SAMPLE_DATA/Tiretread.jmp" );
dtSub = dt << subset( selected columns( 0 ), selected rows( 0 ), output table( "Subset" ) );
For Each Row(
	:Abrasion = :Abrasion + :Abrasion*random normal(0,1);
	:MODULUS = :MODULUS + :MODULUS*random normal(0,1);
	:ELONG = :ELONG + :ELONG * random normal(0,1);
	:HARDNESS = :HARDNESS + :HARDNESS* random normal(0,1);
	
);
dt << Concatenate(
	dtSub,
	Output Table( "Concat of Tiretread, Subset" ),
	Append to first table,
	Create source column
);
Close( dtSub, nosave );

// Run the Model
fm = Fit Model(
	Y( :ABRASION, :MODULUS, :ELONG, :HARDNESS ),
	By( :Source Table ),
	Effects( :SILICA, :SILANE, :SULFUR ),
	Personality( "Standard Least Squares" ),
	Emphasis( "Effect Leverage" ),
	Run(
		:ABRASION << {Summary of Fit( 1 ), Analysis of Variance( 1 ), Parameter Estimates( 1 ),
		Scaled Estimates( 0 ), Plot Actual by Predicted( 1 ), Plot Regression( 0 ),
		Plot Residual by Predicted( 1 ), Plot Studentized Residuals( 0 ),
		Plot Effect Leverage( 1 ), Plot Residual by Normal Quantiles( 0 ),
		Box Cox Y Transformation( 0 )},
		:MODULUS << {Summary of Fit( 1 ), Analysis of Variance( 1 ), Parameter Estimates( 1 ),
		Scaled Estimates( 0 ), Plot Actual by Predicted( 1 ), Plot Regression( 0 ),
		Plot Residual by Predicted( 1 ), Plot Studentized Residuals( 0 ),
		Plot Effect Leverage( 1 ), Plot Residual by Normal Quantiles( 0 ),
		Box Cox Y Transformation( 0 )},
		:ELONG << {Summary of Fit( 1 ), Analysis of Variance( 1 ), Parameter Estimates( 1 ),
		Scaled Estimates( 0 ), Plot Actual by Predicted( 1 ), Plot Regression( 0 ),
		Plot Residual by Predicted( 1 ), Plot Studentized Residuals( 0 ),
		Plot Effect Leverage( 1 ), Plot Residual by Normal Quantiles( 0 ),
		Box Cox Y Transformation( 0 )},
		:HARDNESS << {Summary of Fit( 1 ), Analysis of Variance( 1 ), Parameter Estimates( 1 ),
		Scaled Estimates( 0 ), Plot Actual by Predicted( 1 ), Plot Regression( 0 ),
		Plot Residual by Predicted( 1 ), Plot Studentized Residuals( 0 ),
		Plot Effect Leverage( 1 ), Plot Residual by Normal Quantiles( 0 ),
		Box Cox Y Transformation( 0 )},
		Profiler(
			1,
			Confidence Intervals( 1 ),
			Desirability Functions( 1 )
		)
	)
);
// Stop the JSL
stop();

// Set the Maximize Desirability and the run the code below

// Create an output table
dtMax = New Table( "Desirability",
	New Column( "By Group", character ),
	New Column( "Silica" ),
	New Column( "Silane" ),
	New Column( "Sulfer" ),
	New Column( "Optimized Abrasion"),
	New Column( "Optimized Modulus"),
	New Column( "Optimized Elong"),
	New Column( "Optimized Hardness")
);

// Populate the table getting the Desirability values from the chart
// In this example, the 2 by groups are actually just a replicate of the same
// data, so the output values will be the same.
For( i=1,i<=nitems(fm), i++,
	dtMax << add rows( 1 );
	:By Group[N Rows( dtMax )] = Report( fm[i] )[Outline Box( 1 )] << get title;
	:Silica[N Rows( dtMax )] = Report( fm[i] )["Prediction Profiler"][Number Edit Box( 1 )]
	 << get;
	:Silane[N Rows( dtMax )] = Report( fm[i] )["Prediction Profiler"][Number Edit Box( 2 )]
	 << get;
	:Sulfer[N Rows( dtMax )] = Report( fm[i] )["Prediction Profiler"][Number Edit Box( 3 )]
	 << get;
	:Optimized Abrasion[N Rows( dtMax )] = Num(Report( fm[i] )["Prediction Profiler",TextBox(2)]
	<<get text);
	:Optimized Modulus[N Rows( dtMax )] = Num(Report( fm[i] )["Prediction Profiler",TextBox(6)]
	<<get text);
	:Optimized Elong[N Rows( dtMax )] = Num(Report( fm[i] )["Prediction Profiler",TextBox(10)]
	<<get text);
	:Optimized Hardness[N Rows( dtMax )] = Num(Report( fm[i] )["Prediction Profiler",TextBox(14)]
	<<get text);
);

Now comes your work.  You need to study the provided JSL and learn what it is doing.  Cutting and pasting code without understanding what it is doing is not a good practice.  Please take the time to learn about the functions used, and also about Display Tree output and how to interpret and use the values from the output displays.  When you run into understanding issues, please come back to the Discussion Community for help.

 

Jim

View solution in original post

4 REPLIES 4
txnelson
Super User

Re: Extracting outputs after maximizing desirability functions

Here is an example of doing what you want.  The example creates a sample table. Then runs the Fit Model.  You will have to Maximize Desirability and then run the remainder of the code to get the new output table

txnelson_0-1717592975085.png

Names Default To Here( 1 );
dt = 
// Open Data Table: Tiretread.jmp
// → Data Table( "Tiretread" )
Open( "$SAMPLE_DATA/Tiretread.jmp" );
dtSub = dt << subset( selected columns( 0 ), selected rows( 0 ), output table( "Subset" ) );
For Each Row(
	:Abrasion = :Abrasion + :Abrasion*random normal(0,1);
	:MODULUS = :MODULUS + :MODULUS*random normal(0,1);
	:ELONG = :ELONG + :ELONG * random normal(0,1);
	:HARDNESS = :HARDNESS + :HARDNESS* random normal(0,1);
	
);
dt << Concatenate(
	dtSub,
	Output Table( "Concat of Tiretread, Subset" ),
	Append to first table,
	Create source column
);
Close( dtSub, nosave );

// Run the Model
fm = Fit Model(
	Y( :ABRASION, :MODULUS, :ELONG, :HARDNESS ),
	By( :Source Table ),
	Effects( :SILICA, :SILANE, :SULFUR ),
	Personality( "Standard Least Squares" ),
	Emphasis( "Effect Leverage" ),
	Run(
		:ABRASION << {Summary of Fit( 1 ), Analysis of Variance( 1 ), Parameter Estimates( 1 ),
		Scaled Estimates( 0 ), Plot Actual by Predicted( 1 ), Plot Regression( 0 ),
		Plot Residual by Predicted( 1 ), Plot Studentized Residuals( 0 ),
		Plot Effect Leverage( 1 ), Plot Residual by Normal Quantiles( 0 ),
		Box Cox Y Transformation( 0 )},
		:MODULUS << {Summary of Fit( 1 ), Analysis of Variance( 1 ), Parameter Estimates( 1 ),
		Scaled Estimates( 0 ), Plot Actual by Predicted( 1 ), Plot Regression( 0 ),
		Plot Residual by Predicted( 1 ), Plot Studentized Residuals( 0 ),
		Plot Effect Leverage( 1 ), Plot Residual by Normal Quantiles( 0 ),
		Box Cox Y Transformation( 0 )},
		:ELONG << {Summary of Fit( 1 ), Analysis of Variance( 1 ), Parameter Estimates( 1 ),
		Scaled Estimates( 0 ), Plot Actual by Predicted( 1 ), Plot Regression( 0 ),
		Plot Residual by Predicted( 1 ), Plot Studentized Residuals( 0 ),
		Plot Effect Leverage( 1 ), Plot Residual by Normal Quantiles( 0 ),
		Box Cox Y Transformation( 0 )},
		:HARDNESS << {Summary of Fit( 1 ), Analysis of Variance( 1 ), Parameter Estimates( 1 ),
		Scaled Estimates( 0 ), Plot Actual by Predicted( 1 ), Plot Regression( 0 ),
		Plot Residual by Predicted( 1 ), Plot Studentized Residuals( 0 ),
		Plot Effect Leverage( 1 ), Plot Residual by Normal Quantiles( 0 ),
		Box Cox Y Transformation( 0 )},
		Profiler(
			1,
			Confidence Intervals( 1 ),
			Desirability Functions( 1 )
		)
	)
);
// Stop the JSL
stop();

// Set the Maximize Desirability and the run the code below

// Create an output table
dtMax = New Table( "Desirability",
	New Column( "By Group", character ),
	New Column( "Silica" ),
	New Column( "Silane" ),
	New Column( "Sulfer" )
);

// Populate the table getting the Desirability values from the chart
// In this example, the 2 by groups are actually just a replicate of the same
// data, so the output values will be the same.
For Each( {profile}, fm,
	dtMax << add rows( 1 );
	:By Group[N Rows( dtMax )] = Report( profile )[Outline Box( 1 )] << get title;
	:Silica[N Rows( dtMax )] = Report( profile )["Prediction Profiler"][Number Edit Box( 1 )]
	 << get;
	:Silane[N Rows( dtMax )] = Report( profile )["Prediction Profiler"][Number Edit Box( 2 )]
	 << get;
	:Sulfer[N Rows( dtMax )] = Report( profile )["Prediction Profiler"][Number Edit Box( 3 )]
	 << get;
);
Jim
WipulJ
Level II

Re: Extracting outputs after maximizing desirability functions

Hello Jim,

 

Thank you very much for the code. However it gives an error in the very last section (after the Fit Least Squares is done and after it creates the empty table "Desirability") as follows:

 

WipulJ_0-1718148274099.png

I'm running JMP15.

WipulJ
Level II

Re: Extracting outputs after maximizing desirability functions

Also, how would I save the optimized responses (i.e. Abrasion, Modulus, Elong, Hardness) corresponding to the maximized desirabilities to the same table?

Thanks.

txnelson
Super User

Re: Extracting outputs after maximizing desirability functions

For Each() function was not introduced until JMP 16.  Hence the code needs to be changed to a For() loop methodology.

For( i=1,i<=nitems(fm), i++,

Here is the JSL modified to use the For() function, and to also read in the optimized values for the response variables.  I tested the code in JMP 15

Names Default To Here( 1 );
dt = 
// Open Data Table: Tiretread.jmp
// → Data Table( "Tiretread" )
Open( "$SAMPLE_DATA/Tiretread.jmp" );
dtSub = dt << subset( selected columns( 0 ), selected rows( 0 ), output table( "Subset" ) );
For Each Row(
	:Abrasion = :Abrasion + :Abrasion*random normal(0,1);
	:MODULUS = :MODULUS + :MODULUS*random normal(0,1);
	:ELONG = :ELONG + :ELONG * random normal(0,1);
	:HARDNESS = :HARDNESS + :HARDNESS* random normal(0,1);
	
);
dt << Concatenate(
	dtSub,
	Output Table( "Concat of Tiretread, Subset" ),
	Append to first table,
	Create source column
);
Close( dtSub, nosave );

// Run the Model
fm = Fit Model(
	Y( :ABRASION, :MODULUS, :ELONG, :HARDNESS ),
	By( :Source Table ),
	Effects( :SILICA, :SILANE, :SULFUR ),
	Personality( "Standard Least Squares" ),
	Emphasis( "Effect Leverage" ),
	Run(
		:ABRASION << {Summary of Fit( 1 ), Analysis of Variance( 1 ), Parameter Estimates( 1 ),
		Scaled Estimates( 0 ), Plot Actual by Predicted( 1 ), Plot Regression( 0 ),
		Plot Residual by Predicted( 1 ), Plot Studentized Residuals( 0 ),
		Plot Effect Leverage( 1 ), Plot Residual by Normal Quantiles( 0 ),
		Box Cox Y Transformation( 0 )},
		:MODULUS << {Summary of Fit( 1 ), Analysis of Variance( 1 ), Parameter Estimates( 1 ),
		Scaled Estimates( 0 ), Plot Actual by Predicted( 1 ), Plot Regression( 0 ),
		Plot Residual by Predicted( 1 ), Plot Studentized Residuals( 0 ),
		Plot Effect Leverage( 1 ), Plot Residual by Normal Quantiles( 0 ),
		Box Cox Y Transformation( 0 )},
		:ELONG << {Summary of Fit( 1 ), Analysis of Variance( 1 ), Parameter Estimates( 1 ),
		Scaled Estimates( 0 ), Plot Actual by Predicted( 1 ), Plot Regression( 0 ),
		Plot Residual by Predicted( 1 ), Plot Studentized Residuals( 0 ),
		Plot Effect Leverage( 1 ), Plot Residual by Normal Quantiles( 0 ),
		Box Cox Y Transformation( 0 )},
		:HARDNESS << {Summary of Fit( 1 ), Analysis of Variance( 1 ), Parameter Estimates( 1 ),
		Scaled Estimates( 0 ), Plot Actual by Predicted( 1 ), Plot Regression( 0 ),
		Plot Residual by Predicted( 1 ), Plot Studentized Residuals( 0 ),
		Plot Effect Leverage( 1 ), Plot Residual by Normal Quantiles( 0 ),
		Box Cox Y Transformation( 0 )},
		Profiler(
			1,
			Confidence Intervals( 1 ),
			Desirability Functions( 1 )
		)
	)
);
// Stop the JSL
stop();

// Set the Maximize Desirability and the run the code below

// Create an output table
dtMax = New Table( "Desirability",
	New Column( "By Group", character ),
	New Column( "Silica" ),
	New Column( "Silane" ),
	New Column( "Sulfer" ),
	New Column( "Optimized Abrasion"),
	New Column( "Optimized Modulus"),
	New Column( "Optimized Elong"),
	New Column( "Optimized Hardness")
);

// Populate the table getting the Desirability values from the chart
// In this example, the 2 by groups are actually just a replicate of the same
// data, so the output values will be the same.
For( i=1,i<=nitems(fm), i++,
	dtMax << add rows( 1 );
	:By Group[N Rows( dtMax )] = Report( fm[i] )[Outline Box( 1 )] << get title;
	:Silica[N Rows( dtMax )] = Report( fm[i] )["Prediction Profiler"][Number Edit Box( 1 )]
	 << get;
	:Silane[N Rows( dtMax )] = Report( fm[i] )["Prediction Profiler"][Number Edit Box( 2 )]
	 << get;
	:Sulfer[N Rows( dtMax )] = Report( fm[i] )["Prediction Profiler"][Number Edit Box( 3 )]
	 << get;
	:Optimized Abrasion[N Rows( dtMax )] = Num(Report( fm[i] )["Prediction Profiler",TextBox(2)]
	<<get text);
	:Optimized Modulus[N Rows( dtMax )] = Num(Report( fm[i] )["Prediction Profiler",TextBox(6)]
	<<get text);
	:Optimized Elong[N Rows( dtMax )] = Num(Report( fm[i] )["Prediction Profiler",TextBox(10)]
	<<get text);
	:Optimized Hardness[N Rows( dtMax )] = Num(Report( fm[i] )["Prediction Profiler",TextBox(14)]
	<<get text);
);

Now comes your work.  You need to study the provided JSL and learn what it is doing.  Cutting and pasting code without understanding what it is doing is not a good practice.  Please take the time to learn about the functions used, and also about Display Tree output and how to interpret and use the values from the output displays.  When you run into understanding issues, please come back to the Discussion Community for help.

 

Jim