Chapter 10: Analyses
Question 10.4: How do I use global variables for limit values in a Control Chart script?
Question 10.6: How do you save limits from the Control Chart analysis into the column property?
Question 10.7: How do you save limits from the Control Chart analysis into a new table?
Question 10.8: How can I use spec limits that are stored in a separate data table?
Question 10.10: I need to close the Fit Model dialog window. How do I reference it?
Question 10.11: How can I use a list in place of the Fit Model effects?
In order to create a data table from a report table, send the Make into Data Table message to the Table Box located within the outline box of choice. In this case, the message is sent to the table box in the Parameter Estimates outline box.
/* Open the Big Class sample data table */
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
/* Generate the Bivariate using Age as the By variable */
biv = dt << Bivariate( Y( :height ), X( :weight ), Fit Line );
/* Create the combined data table of Parameter Estimates */
Report( biv )["Parameter Estimates"][Table Box( 1 )] << Make into Data Table;
The solution uses relative referencing of the Table Box. After the report object is referenced, Report(biv), the quoted outline box name is used, followed by the Table Box number, [“Parameter Estimates”][Table Box(1)]. Notice that when examining the report, you can see that the Parameter Estimates outline box holds only one Table Box.
For more information about using relative referencing to access elements in a report, please see the “Display Boxes” topic in chapter 3 and the “Subscripting” topic in chapter 7.
Figure 10.1 Report Showing Parameter Estimates
Figure 10.2 The Data Table Result from Make Into Data Table
Send the Make Combined Data Table message to one of the Bivariate reports to create one data table with parameter estimate values from each By group report:
/* Open the Big Class sample data table */
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
/* Generate the Bivariate using Age as the By variable */
biv = Bivariate( Y( :height ), X( :weight ), Fit Line, By( :age ) );
/* Create the combined data table of Parameter Estimates */
Report( biv[1] )["Parameter Estimates"][Table Box( 1 )] << Make Combined Data Table;
The report generated in this example contains a Bivariate report for each of the six members of the By group age. You need only send the Make Combined Data Table message to one of these reports to make a combined data table for all. In this case, the message was sent to the biv[1] report. The results would be the same if you sent the message to biv[2] or biv[3] reports.
The solution uses relative referencing of the Table Box. After the report object is referenced, Report( biv[1] ), the quoted outline box name is used, followed by the Table Box number, ["Parameter Estimates"][Table Box( 1 )]. Notice that when examining the report, you can see that the Parameter Estimates outline box holds only one Table Box.
For more information on relative referencing, please see the “Display Boxes” topic in chapter 3 and the “Subscripting” topic in chapter 7.
Figure 10.3 Bivariate Report Showing Parameter Estimates
Figure 10.4 The Data Table Result from Make Combined Data Table
In the case of the Neural platform, there are options you can add that belong to a fit rather than the entire report. This is a special case requiring special consideration .
To add the Prediction Profiler to the report, send the Profiler(1) message to Fit, subscripting it, as there can be more than one model in the platform report. Then send the reference that results to the Neural platform reference:
/* Open the sample data table, Boston Housing.jmp */
dt = Open( "$SAMPLE_DATA/Boston Housing.jmp" );
/* Create the Neural Report */
neu = dt << Neural(
Y( :mvalue ),
X( :crim, :zn, :indus, :chas, :nox, :rooms, :age, :distance, :radial, :tax, :pt, :b, :lstat ),
Informative Missing( 0 ),
Transform Covariates( 1 ),
Validation Method( "Holdback", 0.2 ),
Set Random Seed( 1234 ),
Fit( NTanH( 3 ), Transform Covariates( 1 ) )
);
/* Add Profiler option to the Model Report */
neu << (Fit[1] << Profiler( 1 ));
Figure 10.5 Neural Report with Prediction Profiler Added
Initialize your global variables with limit values, and then (as appropriate) use these variables as arguments to LCL, UCL, and AVG, as shown in the following code:
/* Open the sample data table, Pickles.jmp */
dt = Open( "$SAMPLE_DATA/Quality Control/Pickles.jmp" );
/* Assign values to the limits global variables */
upper = 14;
lower = 7;
average = 11;
/* Create Control Chart using the variable values */
cc = dt << Control Chart(
Sample Label( :Date ),
K Sigma( 3 ),
Chart Col( :Acid,
Individual Measurement( UCL( upper ), AVG( average ), LCL( lower ) )
)
);
Figure 10.6 Control Chart with Specified Limits
Use the Get Limits() option in the Control Chart platform object, as shown in the following code:
/* Generate the Control Chart using the Get Limits option with the file path as the argument */
dt = Open( "$SAMPLE_DATA/Quality Control/Coating.jmp" );
cc = dt << Control Chart(
Sample Size( :Sample ),
Chart Col( :Weight, XBar, R ),
Get Limits( "$SAMPLE_DATA/Quality Control/CoatingLimits.jmp" )
);
The argument for the Get Limits() option is the complete file path for the JMP table that contains the limits. The limits table is opened in JMP when this option is used.
Figure 10.7 Limits Table
Figure 10.8 Control Chart with Specified Limits
Send the Save Limits( In Column ) message to the Control Chart object, or include the option in the Control Chart platform launch:
Option 1:
/* Open the Pickles sample data table */
dt = Open( "$SAMPLE_DATA/Quality Control/Pickles.jmp" );
/* Generate the Control Chart */
cc = dt << Control Chart(
Sample Label( :Date ),
K Sigma( 3 ),
Chart Col( :Acid, Individual Measurement, Moving Range )
);
/* Save the limits in a new column */
cc << Save Limits( In Column );
Option 2:
/* Open the Pickles sample data table */
dt = Open( "$SAMPLE_DATA/Quality Control/Pickles.jmp" );
/* Generate the Control Chart using the Save Limits platform option with In Column as the argument. */
cc = dt << Control Chart(
Sample Label( :Date ),
K Sigma( 3 ),
Save Limits( In Column ),
Chart Col( :Acid, Individual Measurement, Moving Range )
);
Option 1 demonstrates how to save the limits to the column property by sending the platform object reference a message. Option 2 accomplishes the same goal but uses the option within the platform launch instead. Specifying an option within a platform or sending a platform object reference a message are methods available in all platforms.
Limits have been saved to the Control Limits column property of the process variable.
Figure 10.9 Saved Limits
Send the Save Limits message to the platform reference using the In New Table argument, as shown in the following code:
/* Open the Pickles sample data table */
dt1 = Open( "$SAMPLE_DATA/Quality Control/Pickles.jmp" );
/* Generate the Control Chart */
cc = dt1 << Control Chart(
Sample Label( :Date ),
Group Size( 1 ),
KSigma(3 ),
Chart Col( :Acid, Individual Measurement, Moving Range )
);
/* Send Save Limits message to platform object */
dt2 = cc << Save Limits( In New Table );
/* Save the new table */
dt2 << Save( "$DOCUMENTS/LimitsTable.jmp" );
The Save Limits option places the limits into a new table. The rest of the code shows the reference to the table, dt2, and then how to save it.
Figure 10.10 Saved Limits Table
Obtain the spec limits stored in one data table, and assign the values to the Spec Limits column property of the desired column in the second table, as shown in the following code:
/* Create a limits table for demonstration purposes */
limitsDt =New Table( "Limits Table",
Add Rows( 3 ),
New Column( "Values", Numeric, Continuous, Format( "Best", 10 ), Set Values( [65, 50, 57] ) ),
New Column( "Spec Limit", Character, Nominal, Set Values( {"Upper", "Lower", "Target"} ) )
);
/* Store the limits in global variables */
lowerSpec = Column( limitsDt, "Values" )[2];
upperSpec = Column( limitsDt, "Values" )[1];
targetSpec = Column( limitsDt, "Values" )[3];
/* Open table where limits will be placed as a column property */
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
/* Create an expression within an expression */
specExpr =Expr(
Column( dt, "height" ) << Set Property(
"Spec Limits",
{LSL( Expr( lowerSpec ) ), USL( Expr( upperSpec ) ), Target( Expr( targetSpec ) )}
)
);
/* Resolve the global variable, then evaluate the main expression */
Eval( Eval Expr( specExpr ) );
/* Perform a distribution that demonstrates that the desired spec limits were used */
dt << Distribution( Continuous Distribution( Column( :height ) ) );
Other options for spec limits can be found in the Manage Spec Limits utility, found at Analyze ► Quality and Process ► Manage Spec Limits.
Figure 10.11 Spec Limits Created in Column Property
Figure 10.12 Distribution Report Result Showing Applied Spec Limits
Specify the stepwise parameters in the Run Model arguments, and then send the Finish message to the platform object. A second Fit Model dialog window is created. Send the Make Model message to this dialog window as shown in the following code:
/* Open a sample data table for demonstration purposes */
dt = Open( "$SAMPLE_DATA/Fitness.jmp" );
/* Launch the Fit Model platform */
fit = dt << Fit Model(
Y( :Oxy ),
Effects( :Weight, :Runtime, :RunPulse, :RstPulse, :MaxPulse ),
Personality( Stepwise ),
Run Model( Prob to Enter( 0.2 ), Direction( Mixed ), Prob to Leave( 0.2 ) )
);
/* Force the stepwise to finish */
fit << Finish;
/* Create the stepped model dialog */
sm = fit << Make Model;
/* Execute the stepped model */
sm << Run Model;
To learn more about the options available for Stepwise Fit Model, go to Help ► Scripting Index, and search on “stepwise”.
Figure 10.13 Stepwise Report
Use Model Dialog[n] as reference, where n refers to the number of the particular dialog window, as shown in the following code:
Model Dialog[1] << Close Window;
Here’s a tip for when there is more than one Model Dialog window to be closed.
If you have two Model Dialog windows open, you can close the first one with this command:
Model Dialog[1] << Close Window;
Use the same command to close the second Model Dialog window, as there will be just one model dialog window left:
Model Dialog[1] << Close Window;
Use the Eval() function to evaluate the myCols variable, as shown in the following code:
/* Open the Big Class sample data table */
dt = Open( "$SAMPLE_DATA/Big Class.JMP" );
/* Assign a global variable to represent the list */
myCols = {:age, :sex, :height};
/* Create Fit Model and use Eval() function to evaluate myCols variable */
fm = dt << Fit Model(
Y( :weight ),
Effects( Eval( myCols ) ),
Personality( Standard Least Squares ),
Run Model(
:weight << {Plot Actual by Predicted( 1 ),
Plot Residual by Predicted( 1 ), Plot Effect Leverage( 1 )}
)
);
Figure 10.14 Fit Model Dialog Window with Model Effects Added
Nest the Save Principal Components and Eigenvectors options inside the Principal Components option for the multivariate analysis. Specify the number of principal components to be saved to the data table as the argument for Save Principal Components.
/* Open the Solubility sample data table. */
dt = Open( "$SAMPLE_DATA/Solubility.jmp" );
/* Create multivariate analysis with Principal Components Arguments. */
mult = dt << Multivariate(
Y( :Name( "1-Octanol" ), :Ether, :Chloroform, :Benzene, :Carbon Tetrachloride, :Hexane ),
Correlations Multivariate( 0 ),
Principal Components( on Correlations, Save Principal Components( 3 ), Eigenvectors )
);
/* Send message to EigenVectors table to create a data table */
newDt = Report( mult )["Eigenvectors"][Table Box( 1 )] << Make Into Data Table;
/* Name the new table. */
newDt << Set Name( "Eigenvectors" );
Figure 10.15 Eigenvectors Table
Option 1:
/* Open the sample data table, Solubility.jmp */
dt = Open( "$SAMPLE_DATA/Solubility.jmp" );
/* Create multivariate analysis */
mult = dt << Multivariate(
Y( :Ether, :Name( "1-Octanol" ), :Carbon Tetrachloride, :Benzene, :Hexane, :Chloroform ),
Estimation Method( "REML" ),
Scatterplot Matrix( Density Ellipses( 1 ), Shaded Ellipses( 0 ), Ellipse Color( 3 ) ),
/* Set option for Mahalanobis and save values to table */
Mahalanobis Distances( 1, Save Outlier Distances( 1 ) ),
/* Set option for Jackknife and save values to table */
Jackknife Distances( 1, Save Jackknife Distances( 1 ) ),
/* Set option for T square and save values to table */
Tsquare( 1, Save Tsquare( 1 ) )
);
/*** Alternate Method***/
/* Open the sample data table, Solubility.jmp */
dt = Open( "$SAMPLE_DATA/Solubility.jmp" );
/* Create multivariate analysis */
mult = dt << Multivariate(
Y( :Ether, :Name( "1-Octanol" ), :Carbon Tetrachloride, :Benzene, :Hexane, :Chloroform ),
Estimation Method( "REML" ),
Scatterplot Matrix( Density Ellipses( 1 ), Shaded Ellipses( 0 ), Ellipse Color( 3 ) )
);
/* Set option for Mahalanobis and save values to table */
mult << Mahalanobis Distances( 1, Save Outlier Distances( 1 ) );
/* Set option for Jackknife and save values to table */
mult << Jackknife Distances( 1, Save Jackknife Distances( 1 ) );
/* Set option for T square and save values to table */
mult << Tsquare( 1, Save Tsquare( 1 ) );
Option 2:
/* Open the sample data table, Solubility.jmp */
dt = Open( "$SAMPLE_DATA/Solubility.jmp" );
/* Create multivariate analysis */
mult = dt << Multivariate(
Y( :Ether, :Name( "1-Octanol" ), :Carbon Tetrachloride, :Benzene, :Hexane, :Chloroform ),
Estimation Method( "REML" ),
Scatterplot Matrix( Density Ellipses( 1 ), Shaded Ellipses( 0 ), Ellipse Color( 3 ) )
);
/* Set option for Mahalanobis and save values to table */
mult << Mahalanobis Distances( 1, Save Outlier Distances( 1 ) );
/* Set option for Jackknife and save values to table */
mult << Jackknife Distances( 1, Save Jackknife Distances( 1 ) );
/* Set option for T square and save values to table */
mult << Tsquare( 1, Save Tsquare( 1 ) );
Mahalanobis(1), Jackknife(1), and Tsquare(1) are the messages to create these analyses in the multivariate report. To save the values that these reports generate as new columns in the data table, use the Save option nested within that argument.
You can use the terms Tsquare, T Square, or T² interchangeably.
Figure 10.16 Table with Mahalanobis, Jackknife, and T-Square Values Saved