<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Retrieve simplified prediction formula by script in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Retrieve-simplified-prediction-formula-by-script/m-p/386113#M63624</link>
    <description>&lt;P&gt;In the example I gave it is left as Expression. I think you will have to first convert it into string with:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;simplified_formula_str = Char(simplified_formula);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;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:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1621313082202.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/32914iCCCBB4E6A75FE75C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1621313082202.png" alt="jthi_0-1621313082202.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After you have list of values, you can use Set Values to add values to datatable:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;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)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 18 May 2021 04:53:25 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2021-05-18T04:53:25Z</dc:date>
    <item>
      <title>Retrieve simplified prediction formula by script</title>
      <link>https://community.jmp.com/t5/Discussions/Retrieve-simplified-prediction-formula-by-script/m-p/385733#M63584</link>
      <description>&lt;P&gt;Hello, I'm quite new to the JMP script but I'm trying to get the coefficients of the prediction formula from fitted models.&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Save Columns==&amp;gt;Prediction Formula==&amp;gt;Open up the formula from the data table==&amp;gt;From the red triangle pop up menu of the equation editor, choose simplify&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="prediction3.PNG" style="width: 992px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/32881i96DBBABC3529452E/image-size/large?v=v2&amp;amp;px=999" role="button" title="prediction3.PNG" alt="prediction3.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My ideal picture is to obtain the simplified formula coefficients in a new data table, similar to right click in "Parameter Estimates" ==&amp;gt; "Make into (combined) Data Table"&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="123.png" style="width: 759px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/32883i788ABEA61F58AED7/image-size/large?v=v2&amp;amp;px=999" role="button" title="123.png" alt="123.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open( "$SAMPLE_DATA/Tiretread.jmp" );
obj = dt &amp;lt;&amp;lt; Fit Model(
	Y( :ABRASION ),
	Effects(
		:SILICA &amp;amp; RS, :SILANE &amp;amp; RS, :SILICA * :SILICA, :SILICA * :SILANE,
		:SILANE * :SILANE
	),
	Personality( "Standard Least Squares" ),
	Emphasis( "Effect Screening" ),
	Run(
		Profiler(
			1,
			Confidence Intervals( 1 ),
			Desirability Functions( 1 ),
			ABRASION &amp;lt;&amp;lt; 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 &amp;lt;&amp;lt; {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 )}
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Appreciate if anyone with experiences can help!&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:30:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Retrieve-simplified-prediction-formula-by-script/m-p/385733#M63584</guid>
      <dc:creator>cschen</dc:creator>
      <dc:date>2023-06-10T23:30:17Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve simplified prediction formula by script</title>
      <link>https://community.jmp.com/t5/Discussions/Retrieve-simplified-prediction-formula-by-script/m-p/385748#M63585</link>
      <description>&lt;P&gt;You can get the simplified formula with something like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;col_formula = Expr(Column(dt, "Pred Formula ABRASION") &amp;lt;&amp;lt; Get Formula);&lt;BR /&gt;simplified_formula = Expr(Simplify Expr(col_formula));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And you can script the Make Into datatable from Fit model:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt_new = ((obj &amp;lt;&amp;lt; report)["Parameter Estimates"])[TableBox(1)]&amp;lt;&amp;lt; Make Into Data Table;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Check Scripting Index for great source of JSL scripting.&lt;/P&gt;</description>
      <pubDate>Mon, 17 May 2021 09:46:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Retrieve-simplified-prediction-formula-by-script/m-p/385748#M63585</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-05-17T09:46:33Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve simplified prediction formula by script</title>
      <link>https://community.jmp.com/t5/Discussions/Retrieve-simplified-prediction-formula-by-script/m-p/386103#M63621</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;The first one is exactly what I want.&lt;/P&gt;&lt;P&gt;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".&lt;/P&gt;&lt;P&gt;If using the original Make Into Data Table function, it creates a table contains the coefficients from the "non-simplified" ones.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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)?&lt;/P&gt;&lt;P&gt;I was trying to parse it or change it to a matrix or table, but none of them work so far.&lt;/P&gt;&lt;P&gt;(I'm not sure what's the type of the formula object...text?)&lt;/P&gt;</description>
      <pubDate>Tue, 18 May 2021 01:35:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Retrieve-simplified-prediction-formula-by-script/m-p/386103#M63621</guid>
      <dc:creator>cschen</dc:creator>
      <dc:date>2021-05-18T01:35:42Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve simplified prediction formula by script</title>
      <link>https://community.jmp.com/t5/Discussions/Retrieve-simplified-prediction-formula-by-script/m-p/386113#M63624</link>
      <description>&lt;P&gt;In the example I gave it is left as Expression. I think you will have to first convert it into string with:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;simplified_formula_str = Char(simplified_formula);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;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:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1621313082202.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/32914iCCCBB4E6A75FE75C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1621313082202.png" alt="jthi_0-1621313082202.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After you have list of values, you can use Set Values to add values to datatable:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;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)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 May 2021 04:53:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Retrieve-simplified-prediction-formula-by-script/m-p/386113#M63624</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-05-18T04:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve simplified prediction formula by script</title>
      <link>https://community.jmp.com/t5/Discussions/Retrieve-simplified-prediction-formula-by-script/m-p/386321#M63636</link>
      <description>&lt;P&gt;You 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.&lt;/P&gt;</description>
      <pubDate>Tue, 18 May 2021 13:37:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Retrieve-simplified-prediction-formula-by-script/m-p/386321#M63636</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2021-05-18T13:37:31Z</dc:date>
    </item>
  </channel>
</rss>

