通过脚本检索简化的预测公式您好,我对 JMP 脚本很陌生,但我正在尝试从拟合模型中获取预测公式的系数。
已经有很多帖子描述了如何在脚本中获取预测公式,但我想要的是在JMP界面中应用“简化”后的公式。
保存列==>预测公式==>从数据表中打开公式==>从方程编辑器的红色小三角弹出菜单中,选择简化

我理想的情况是在一个新的数据表中得到简化的公式系数,类似于右键“参数估计”==>“制作成(组合)数据表”

我有构建拟合模型的代码,但我不知道如何包含简化函数并将其保存回新表。
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 )}
)
)
);
如果有经验的人可以帮忙,不胜感激!
数据存取回复:通过脚本检索简化的预测公式您也可以直接解析表达式。 请参阅 JMP 帮助或脚本索引以了解 Head()、N Args() 和 Arg() 函数。 您可以将表达式作为树或链接列表进行遍历。
回复:通过脚本检索简化的预测公式在我给出的示例中,它保留为表达式。 我认为你必须首先将其转换为字符串:
simplified_formula_str = Char(simplified_formula);
然后从那里开始将其解析为列表。 对于解析,以下函数可能会帮助您入门:Words()、Substitute()(以及 Regex,如果您知道如何使用它)。 更多功能可以在脚本索引中找到:

获得值列表后,您可以使用设置值将值添加到数据表:
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)
)
);
回复:通过脚本检索简化的预测公式@jthi
谢谢!
第一个正是我想要的。
但我想创建一个新表,显示简化公式(如“生成数据表”)中的系数和变量。
如果使用原始的“生成数据表”功能,它会创建一个包含“非简化”系数的表。
既然已经保存了simplified_formula,有没有办法将其转换为表格(不是预测值,只是系数和变量)?
我试图解析它或将其更改为矩阵或表格,但到目前为止它们都不起作用。
(我不确定公式对象的类型是什么...文本?)
回复:通过脚本检索简化的预测公式您可以通过以下方式获得简化的公式:
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 脚本的重要来源。