如何使用 JSL 从 Fit Curve 平台提取拟合参数?我刚开始学习 JSL 编程,一直想实现 Fit Curve 平台相关工作流程的自动化,但遇到了困难。以下是我想要自动化的内容:
步骤 1:通过提供 X、Y 和 BY 数据,将曲线指数 2P 模型拟合到数据。以下脚本代码运行正常。
步骤 2:收集拟合参数:每个样本 ID 的尺度和增长率(我希望它们只是“a”和“b” ),并创建一个新表,该表包含以下列:“样本 ID”、“尺度”或“a”、“增长率”或“b”、“数据点数”(用于拟合)。
- 这就是我遇到的难题。我可以创建一个带有合适标题的新表格(见下方脚本),但我不知道如何与“拟合曲线”报告交互,提取每个样本 ID 的拟合值,然后用这些值填充每个样本 ID 对应的一行。我尝试过使用 JMP 助手和 Claude 来帮忙编写代码,但他们都无法从报告中提取这些信息。
步骤 3:在这个新表格中添加两列:“TOS = 60 时的预测”和“预测的不确定性”,并使用指数 2P 公式 (y = a*exp(b*x)) 进行预测,并使用参数的拟合误差来估计 TOS = 60 时值的不确定性。
谢谢你的帮助!
戴夫
New Column( "Conversion at 60 hr", Numeric, Continuous ),
New Column( "Error of Estimate", Numeric, Continuous )
);Fit Curve(
Y( :Conversion ),
X( :TOS ),
Fit Exponential 2P,
By( :Sample ID )
);<BR />results_dt = New Table( "Exponential Fit Results",<BR />Add Rows( 0 ),<BR />New Column( "Sample ID" ),<BR />New Column( "a", Numeric, Continuous ),<BR />New Column( "b", Numeric, Continuous ),<BR /><CODE class="language-jsl">New Column( "Number of Points", Numeric, Continuous ),
自动化和脚本编写回复:关于如何使用 JSL 从 Fit Curve 平台提取拟合参数的帮助右键单击其中一个结果表,将其合并为数据表

然后,您可以从生成的表格中调用“创建合并数据表”脚本。这能让您很好地了解您可以做什么。
Names Default To Here(1);
rpt = New Window("Bioassay - Fit Curve of Toxicity by log Conc",
Data Table("Bioassay") << Fit Curve(
Y(:Toxicity),
X(:log Conc),
Fit Exponential 2P,
By(:Formulation)
)
);
Wait(0);
rpt["Fit Curve", "Formulation=standard", "Exponential 2P", "Parameter Estimates",
Table Box(1)] << Make Combined Data Table;
rpt << Close Window;

然后,您可以根据该表使用不同的表格平台(例如汇总、拆分和更新)来创建最终表格。


回复:关于如何使用 JSL 从 Fit Curve 平台提取拟合参数的帮助感谢您的回复。我之前也考虑过这种方法,但以为可以直接从每个表中提取变量,而不是先提取整个表再重新格式化以满足我的需求。非常感谢您清晰的解释。
回复:关于如何使用 JSL 从 Fit Curve 平台提取拟合参数的帮助你可以这样做,但通常先将其转换为表格,然后再从那里开始操作会更容易。
回复:关于如何使用 JSL 从 Fit Curve 平台提取拟合参数的帮助这里还有另一种使用 XPath 搜索报表结构的方法。我并不认为这种方法更简单,但我发现它更健壮,如果出现意外情况(例如第三个表不再是第三个表),它会发出明确的错误信息,而不是仅仅返回错误的值,尤其是在添加一些检查并在出现意外值时抛出错误的情况下。我确实认为这应该更容易一些,所以我厚颜无耻地提出我的愿望清单,至少为这些操作构建包装器: 让通过 JSL 从报表中获取结果变得更加容易。
Names Default To Here( 1 );
// Example fit
dt = Open( "$SAMPLE_DATA/Nonlinear Examples/Bioassay.jmp" );
curves = dt << Fit Curve(
Y( :Toxicity ),
X( :log Conc ),
Fit Exponential 2P,
By( :Formulation )
);
// Run this to inspect the report's XML structure — it's the key to
// writing the XPath expressions below. Combine with web searches on
// XPath syntax (//, ancestor::, parent::, text(), etc.) as needed.
curves << Get XML;
// Find the right fit by matching the outline box heading — return the first match
curve = filter each( {c}, curves, length( c << XPath( "/OutlineBox[text()='Formulation=standard']" ) ) > 0 )[1];
// Find columns labeled 'Parameter' inside an outline box called 'Parameter Estimates'
// inside a box called 'Exponential 2P', then find the grandparent TableBox and return
// the first one (there should only be one — you can verify with
// if( N Items( ... ) > 1, throw( ... ) )
// Single XPath split across lines for readability; the || concatenates the fragments.
paramTableRef = (curve << XPath(
"//OutlineBox[text()='Exponential 2P']"
|| "//OutlineBox[text()='Parameter Estimates']"
|| "//StringColBoxHeader[text()='Parameter']"
|| "//ancestor::TableBox"
))[1];
// Alternative approach: you could grab the whole table as a list and parse it directly:
paramTableList = paramTableRef << Get;
Show( paramTableList );
// Sticking with XPath for now: find that StringColBoxHeader again, find its parent, and get
// the parameter names (again, assumes there is only one matching column).
paramNames = (paramTableRef << XPath( "//StringColBoxHeader[text()='Parameter']//parent::StringColBox" ))[1] << Get;
// Now get the estimates
paramEstimates = (paramTableRef << XPath( "//NumberColBoxHeader[text()='Estimate']//parent::NumberColBox" ))[1] << Get;
// Put them in an associative array
arrParamEstimates = Associative Array( paramNames, paramEstimates );
// And now you have the values keyed by parameter name
Show( arrParamEstimates["Growth Rate"], arrParamEstimates["Scale"] );