Retrieve simplified prediction formula by scriptHello, I'm quite new to the JMP script but I'm trying to get the coefficients of the prediction formula from fitted models.
There are already many posts describing how to obtain the prediction formula in scripts, but what I want is the formula after applying "Simplify" in the JMP interface.
Save Columns==>Prediction Formula==>Open up the formula from the data table==>From the red triangle pop up menu of the equation editor, choose simplify

My ideal picture is to obtain the simplified formula coefficients in a new data table, similar to right click in "Parameter Estimates" ==> "Make into (combined) Data Table"

I have the code for constructing the fitted model, but I don't know how to include the simplified function and save it back to a new table.
dt = Open( "$SAMPLE_DATA/Tiretread.jmp" );
obj = dt << Fit Model(
Y( :ABRASION ),
Effects(
:SILICA & RS, :SILANE & RS, :SILICA * :SILICA, :SILICA * :SILANE,
:SILANE * :SILANE
),
Personality( "Standard Least Squares" ),
Emphasis( "Effect Screening" ),
Run(
Profiler(
1,
Confidence Intervals( 1 ),
Desirability Functions( 1 ),
ABRASION << Response Limits(
{Lower( 100, 0.066 ), Middle( 150, 0.5 ),
Upper( 200, 0.9819 ), Goal( "Maximize" ), Importance( 0.25 )}
),
Term Value(
SILICA( 1.2, Lock( 0 ), Show( 1 ) ),
SILANE( 50, Lock( 0 ), Show( 1 ) )
)
),
:ABRASION << {Summary of Fit( 0 ), Analysis of Variance( 0 ),
Parameter Estimates( 1 ), Effect Details( 0 ), Sorted Estimates( 0 ),
Plot Actual by Predicted( 1 ), Plot Regression( 0 ),
Plot Residual by Predicted( 1 ), Plot Studentized Residuals( 1 ),
Plot Effect Leverage( 0 ), Plot Residual by Normal Quantiles( 0 ),
Box Cox Y Transformation( 1 )}
),
SendToReport(
Dispatch(
{"Response ABRASION"},
"Parameter Estimates",
OutlineBox,
{Close( 0 )}
)
)
);
Appreciate if anyone with experiences can help!
Data TableScriptingRe: Retrieve simplified prediction formula by scriptYou can also parse the expression directly. See JMP Help or Scripting Index to learn about the Head(), N Args(), and Arg() functions. You traverse the expression as a tree or linked list.
Re: Retrieve simplified prediction formula by scriptIn the example I gave it is left as Expression. I think you will have to first convert it into string with:
simplified_formula_str = Char(simplified_formula);
And from there start parsing it into lists. For parsing following functions might get you started: Words(), Substitute() (and Regex if you know how to use it). More functions can be found from Scripting Index:

After you have list of values, you can use Set Values to add values to datatable:
Names Default To Here(1);
intercept_list = {"Intercept", "SILICA"};
estimate_list = [123, 1];
New Table("Untitled",
Add Rows(2),
Compress File When Saved(1),
New Column("Term", Character, "Nominal", Set Values(intercept_list)),
New Column("Estimate",
Numeric,
"Continuous",
Format("Best", 12),
Set Values(estimate_list)
)
);
Re: Retrieve simplified prediction formula by script@jthi
Thanks!
The first one is exactly what I want.
But I want to create a new table which shows the coefficients and the variables from the simplified formula like the "Make Into Data Table".
If using the original Make Into Data Table function, it creates a table contains the coefficients from the "non-simplified" ones.
As now the simplified_formula has been saved, is there a way to transform it to a table (not the prediction value, just the coefficients and variables)?
I was trying to parse it or change it to a matrix or table, but none of them work so far.
(I'm not sure what's the type of the formula object...text?)
Re: Retrieve simplified prediction formula by scriptYou can get the simplified formula with something like this:
col_formula = Expr(Column(dt, "Pred Formula ABRASION") << Get Formula);<BR />simplified_formula = Expr(Simplify Expr(col_formula));
And you can script the Make Into datatable from Fit model:
dt_new = ((obj << report)["Parameter Estimates"])[TableBox(1)]<< Make Into Data Table;
Check Scripting Index for great source of JSL scripting.