Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Discussions
- :
- JSL - Save Best Transformation

Topic Options

- Start Article
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Mar 1, 2017 2:08 AM
(2122 views)

Hi,

I'm running the script below and it will stop after the box-cox outline box generation. What i do is then is to manually 'Save Best Transformation' in the 'Box Cox Transformation' outline box. My question, Is there a way to automate the 'Save Best Transformation' via JSL to continue with the script on more items to transform? thanks to help

-Rgsd, Joel

Clear Log();

dtName = "Big Class";

dt = Open( "$SAMPLE_DATA/" || dtName || ".jmp" );

nwd = New Window( "Box Cox",

dt << Fit Model(

Y( :weight ),

Effects,

Personality( "Standard Least Squares" ),

Emphasis( "Effect Leverage" ),

Run(

:weight << {Summary of Fit( 1 ), Analysis of Variance( 1 ), Parameter Estimates( 1 ), Lack of Fit( 0 ), Plot Actual by Predicted( 1 ),

Plot Regression( 0 ), Plot Residual by Predicted( 1 ), Plot Effect Leverage( 1 ), Box Cox Y Transformation( 1 ),

save best transformation( 1 )}

)

)

);

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

If you create the code you shared in JSL as a string and have all the column names you wish to transform as a list (**colListYBoxCox**) then you can substitute in the column names and loop over all the columns in your list (example below).

I have done this and then checked if the box-cox transformation made a big difference, and automatically deleted those which were a waste of time.

Regards,

Stephen

For( i = 1, i <= N Items( colListYBoxCox ), i++,

boxcoxstring = "boxcoxwindow = Fit Model(

Y(";

boxcoxstring = Concat( boxcoxstring, ":Name(\!"", colListYBoxCox[i], "\!")," );

boxcoxstring = Concat( boxcoxstring, ")," );

boxcoxstring = Concat(

boxcoxstring,

"Effects,

Personality( \!"Standard Least Squares\!" ),

Emphasis( \!"Effect Leverage\!" ),"

);

boxcoxstring = Concat(

boxcoxstring,

"Run(:Name(\!"",

colListYBoxCox[i],

"\!")<< {Lack of Fit( 0 ), Plot Actual by Predicted( 0 ),

Plot Regression( 0 ), Plot Residual by Predicted( 0 ),

Plot Effect Leverage( 0 ), Box Cox Y Transformation( 1, Save Best Transformation( 1 ) ), Show VIF( 1 )},

),"

);

boxcoxstring = Concat( boxcoxstring, ");" );

Eval( Parse( boxcoxstring ) );

Wait( 0 );

boxcoxwindow << Close Window;

);

3 REPLIES 3

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

If you create the code you shared in JSL as a string and have all the column names you wish to transform as a list (**colListYBoxCox**) then you can substitute in the column names and loop over all the columns in your list (example below).

I have done this and then checked if the box-cox transformation made a big difference, and automatically deleted those which were a waste of time.

Regards,

Stephen

For( i = 1, i <= N Items( colListYBoxCox ), i++,

boxcoxstring = "boxcoxwindow = Fit Model(

Y(";

boxcoxstring = Concat( boxcoxstring, ":Name(\!"", colListYBoxCox[i], "\!")," );

boxcoxstring = Concat( boxcoxstring, ")," );

boxcoxstring = Concat(

boxcoxstring,

"Effects,

Personality( \!"Standard Least Squares\!" ),

Emphasis( \!"Effect Leverage\!" ),"

);

boxcoxstring = Concat(

boxcoxstring,

"Run(:Name(\!"",

colListYBoxCox[i],

"\!")<< {Lack of Fit( 0 ), Plot Actual by Predicted( 0 ),

Plot Regression( 0 ), Plot Residual by Predicted( 0 ),

Plot Effect Leverage( 0 ), Box Cox Y Transformation( 1, Save Best Transformation( 1 ) ), Show VIF( 1 )},

),"

);

boxcoxstring = Concat( boxcoxstring, ");" );

Eval( Parse( boxcoxstring ) );

Wait( 0 );

boxcoxwindow << Close Window;

);

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: JSL - Save Best Transformation

Hi stephen_pearson,

Just what i need 'Box Cox Y Transformation( 1, Save Best Transformation( 1 ) )'. Yes i'm running thru multiple selections for this option and its now processing without manual intervention. Thanks

Just what i need 'Box Cox Y Transformation( 1, Save Best Transformation( 1 ) )'. Yes i'm running thru multiple selections for this option and its now processing without manual intervention. Thanks

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: JSL - Save Best Transformation

FYI, here's an alternative that does not require you to build a string. This way, the syntax checking and highlighting in the editor is retained. If you make as many mistakes as I do, that's useful.

```
NamesDefaultToHere(1);
dtName = "Big Class";
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
numericCols = dt << getColumnNames("String", "Numeric");
// Build a function to do what's needed . . .
getBestBoxCox =
Function({numCol}, {Default Local},
// Open the fit model lauch dialog
fmDialog = dt << Fit Model(
Y( Eval(numCol) ),
Effects,
Personality( "Standard Least Squares" ),
Emphasis( "Effect Leverage" )
);
// Run the desired model ('fmAnalysis' is a reference to the analysis layer of the report window)
fmAnalysis = fmDialog << runModel;
// Close the launch dialog
Report(fmDialog) << closeWindow;
// Ask for the transformations
fmAnalysis << Box Cox Y Transformation;
// Get a reference to the little red triangle for the transformations
lrt = Report(fmAnalysis)["Box-Cox Transformations"] << getScriptableObject;
// Save the best transformation
lrt << saveBestTransformation;
// Close the report window
Report(fmAnalysis) << closeWindow;
);
// Use the function on the required columns . . .
for(c=1, c<=NItems(numericCols), c++, getBestBoxCox(numericCols[c]));
```