如何使用 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"] );