For the latest version of JMP Help, visit JMP.com/help.


Publication date: 05/05/2023

Fit Model Scripts

When scripting the Fit Model platform, here are a few general tips for controlling the behavior of the launch window:

To keep the launch window open and fit the model at the same time, do one of the following (they are equivalent):

Include the Run Model message in your script.

Include both the Run message and the Keep Dialog Open(1) message.

To run the model without showing the launch window, include the Run message in your script.

Model Scripts in the Data Table

When a data table contains a Model script and you launch Fit Model interactively, the Fit Model launch window is pre-populated according to the roles assigned by the table script.

Fit Group

If you want to fit different models and see a shared Profiler so that you can compare the models, use the Fit Group function. You can fit models such as least squares, nonlinear, neural, Gaussian processing, and mixed, in the same window with a shared Profiler. The following example creates both a Standard Least Squares model and a Gaussian Process model.

dt = Open( "$SAMPLE_DATA/Tiretread.jmp" );
obj = dt << Fit Group(
	Fit Model(
		Y( :ABRASION ),
		Effects(
			:SILICA & RS,
			:SILANE & RS,
			:SULFUR & RS,
			:SILICA * :SILICA,
			:SILICA * :SILANE,
			:SILANE * :SILANE,
			:SILICA * :SULFUR,
			:SILANE * :SULFUR,
			:SULFUR * :SULFUR
		),
		Personality( "Standard Least Squares" ),
		Emphasis( Minimal Report ),
		Run()
	),
	Gaussian Process(
		Y( :HARDNESS ),
		X( :SILICA, :SILANE, :SULFUR ),
		Set Correlation Function( "Cubic" )
	)
);

In the report, click the Fit Group red triangle and select Profiler. Scroll down to the Prediction Profiler. You can see the ABRASION row for the SLS model, and the HARDNESS row for the Gaussian Process model appearing in the same profiler.

Effects

Effects in the model can be more than just a list of columns, and can have a specialized syntax:

Effects( list of effects, list of effect macros, or both lists );

An effect can be a column name, a crossing of several column names with asterisk (*) notation, or nested columns specified with subscript bracket ([ ]) notation. Additional effect options can appear after an ampersand (&) character. Here are some examples:

A,                  // a column name alone is a main effect
A*B,                // a crossed effect, interaction, or polynomial
A[B],               // nested
A*B[C D],           // crossed and nested
effect&Random,      // a random effect
effect&LogVariance, // a variance model term
effect&RS,          // a response surface term
effect&Mixture,     // for an effect participating in a mixture
effect&Excluded,    // for an effect that with no model arguments
effect&Knotted,     // for a knotted spline effect

Effect macros are:

Factorial( columns ),   // for a full factorial design
Factorial2( columns ),  // for up to 2nd-degree interactions only
Polynomial( columns ),  // for a 2nd-degree polynomial only

Responses and Effects for MANOVA

To address an individual response function analysis, use a subscripted Response:

manovaObj << ( Response[ 1 ] << {response options} );
manovaObj << ( Response[ "Contrast" ] << {response options} );

Each response function supports the Custom Test message:

Custom Test( matrix, <Power Analysis( ... )>, <Label( "..." )> )

where each row of the matrix specifies coefficients for all the arguments in the model.

To address an individual Effect test, use subscripted Effect with a name or number:

manovaObj << ( Response[1] << ( Effect["Whole Model"] << {effect options} ) );
manovaObj << ( Response[1] << ( Effect[i] << {effect options} ) );

The effects are numbered:

0 for the intercept

1, 2, and so on, for regular effects

n+1 for the “Whole Model” test, where n is the number of effects not including the intercept

Each effect in each response function supports the following messages, where each row of the matrix has coefficients for all the levels in the effect:

Test Details( 1 ),
Centroid Plot( 1 ),
Save Canonical Scores,
Contrast( matrix, <Power Analysis(...)> );

For example, the following JSL script adds test details for an effect to the report window:

dt = Open( "$SAMPLE_DATA/Dogs.jmp" );
manObj = dt << Fit Model(
	Y( logHist0, logHist1, logHist3, logHist5 ),
	Effects( dep1, drug, drug * dep1 ),
	Personality( "MANOVA" ),
	Run Model
);
manObj << Response Function( "Contrast" );
manObj << (Response["Contrast"] << (Effect["Whole Model"] <<
 

/* send the Test Details message to the Whole Model outline

under Contrast in the report window */

Test Details( 1 )));
 

/* send the Test Details message to response 1 (Contrast)

and effect 3 (drug*dep1) */

manObj << (Response[1] << (Effect[3] << Test Details( 1 )));

Send Function

Tip: Recall that the << operator is equivalent to the Send() function.

When you have multiple responses, you can send messages to a specific response column’s fit. Use the following JSL (where responseName is the specific response):

fitObj << ( responseName << {options, ...});

The second Send() function finds the named response and sends the list of messages to it.

Note: If you send the messages directly to the fitObj with a single Send() function, the messages are sent to all responses.

In the following script, the last line sends a message to the AICc report for the ABRASION response:

dt = Open( "$SAMPLE_DATA/Tiretread.jmp" );
fitObj = dt << Fit Model(
	Y( :ABRASION, :MODULUS, :ELONG, :HARDNESS ),
	Effects(
		:SILICA & RS,
		:SILANE & RS,
		:SULFUR & RS,
		:SILICA * :SILICA,
		:SILANE * :SILICA,
		:SILANE * :SILANE,
		:SULFUR * :SILICA,
		:SULFUR * :SILANE,
		:SULFUR * :SULFUR
	),
	Personality( "Standard Least Squares" ),
	Run
);

/* shows up under the Studentized Residuals plot*/

fitObj << (:ABRASION << {AICc( 1 )});

To send messages to an individual effect, nest even further:

fitObj << ( responseName << ((effectName) << effectOption ));

Standard Least Squares

For Standard Least Squares models that contain only fixed effects and more than one Y response, you can choose to fit the models for the Y responses together or separately. If some of the rows have missing values, the following apply:

In a script, the Y responses are fit together by default. The model fits each Y using only those rows that are nonmissing for all of the Y variables. For example, a row that includes one or more missing Y values is excluded from the model. You can explicitly include Run( "Fit Together" ) in a script to get the same result.

If you include the Run( "Fit Separately" ) option, the model fits each Y using all rows that are nonmissing for that particular Y. For example, a row that includes one or more missing Y values is included in the model.

The following script fits the Y responses together:

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Fit Model(
	Y( :height, :weight ),
	Effects( :sex ),
	Personality( "Standard Least Squares" ),
	Emphasis( "Minimal Report" ),
	Run // or Run( "Fit Together" )
);

The following script fits the Y responses separately:

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Fit Model(
	Y( :height, :weight ),
	Effects( :sex ),
	Personality( "Standard Least Squares" ),
	Emphasis( "Minimal Report" ),
	Run( "Fit Separately" )
);

When running the model in JMP, the user is prompted to select fitting the responses separately or together. The Fit Model launch window contains a Fit Separately option, which is deselected by default. For more information about how missing Y values are handled, see “Missing Values” in Fitting Linear Models.

Note: In models that contain a random effect, Y values are fit separately by default.

Want more information? Have questions? Get answers in the JMP User Community (community.jmp.com).