通過腳本檢索簡化的預測公式您好,我對 JMP 腳本很陌生,但我正在嘗試從擬合模型中獲取預測公式的係數。
已經有很多帖子描述瞭如何在腳本中獲取預測公式,但我想要的是在JMP界面中應用“簡化”後的公式。
保存列==>預測公式==>從數據表中打開公式==>從公式編輯器的紅色小三角彈出菜單中,選擇簡化

我的理想圖是在新的數據表中獲取簡化公式係數,類似於在“Parameter Estimates”==>“Make into (combined) Data 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 )}
)
)
);
感謝有經驗的人可以提供幫助!
數據表腳本Re: 通過腳本檢索簡化的預測公式您也可以直接解析表達式。 請參閱 JMP 幫助或腳本索引以了解 Head()、N Args() 和 Arg() 函數。 您將表達式作為樹或鍊錶進行遍歷。
Re: 通過腳本檢索簡化的預測公式在我給出的示例中,它保留為表達式。 我認為您必須首先將其轉換為字符串:
simplified_formula_str = Char(simplified_formula);
從那裡開始將其解析為列表。 對於解析以下函數可能會讓您入門:Words()、Substitute()(如果您知道如何使用它,還有 Regex)。 更多功能可以從 Scripting Index 中找到:

獲得值列表後,您可以使用 Set Values 將值添加到數據表:
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: 通過腳本檢索簡化的預測公式@jthi
謝謝!
第一個正是我想要的。
但我想創建一個新表,顯示簡化公式中的係數和變量,如“製作數據表”。
如果使用原始的 Make Into Data Table 函數,它會創建一個包含“非簡化”係數的表。
現在simplified_formula 已經保存了,有沒有辦法將它轉換為表格(不是預測值,只是係數和變量)?
我試圖解析它或將其更改為矩陣或表格,但到目前為止它們都不起作用。
(我不確定公式對象的類型是什麼......文本?)
Re: 通過腳本檢索簡化的預測公式您可以通過以下方式獲得簡化公式:
col_formula = Expr(Column(dt, "Pred Formula ABRASION") << Get Formula);<BR />simplified_formula = Expr(Simplify Expr(col_formula));
您可以從 Fit 模型編寫 Make Into 數據表的腳本:
dt_new = ((obj << report)["Parameter Estimates"])[TableBox(1)]<< Make Into Data Table;
檢查腳本索引以獲得 JSL 腳本的重要來源。