需要從線性最小二乘模型擬合的參數估計表中提取斜率和截距並保存到檔案中我的程式碼無法運作,而且我不知道原因。任何幫助都將不勝感激 - 謝謝!
dt = Open("C:\Users\trcampbell\Desktop\MASTER ECOLI\2025\2024.xlsx");
obj = Fit model(
Y( :LOGECOLI ),
Effects( :LOGTURB),
Personality( "Standard Least Squares" ),
Emphasis( "Effect Leverage" ),
Run(:LOGECOLI )) ;
// Extract slope and intercept
reportObj = obj << Report;
paramTable = reportObj( "Parameter Estimates" );
// Extract values from Parameter Estimates table
intercept = paramTable[estimate(1)]; //1st column
slope = paramTable[estimate(2)]; //2nd column
// Create a new data table to store the results
results = New Table( "Fit Results",
Add Column( "Parameter", Character, Set Values( {"Slope", "Intercept"} ) ),
Add Column( "Value", Numeric, Set Values( {slope, intercept} ) )
);
// Save the results to an Excel spreadsheet
results << Export( "C:\\Users\\trcampbell\\Desktop\\MASTER ECOLI\\2025\\validation results\\test xxx.xlsx");
自動化和腳本回覆:需要從線性最小二乘模型擬合的參數估計表中提取斜率和截距並保存到文件中你好@learning_JSL ,
我已經修改了您的腳本,以利用“製作成數據表”功能來帶來詳細信息,但我還通過更改參數表以針對錶的特定估計部分添加了您在腳本中遇到的挑戰 - 如果您想找到如何執行此操作,最好右鍵單擊>屬性並突出顯示估計部分以找到對象的路徑。
我在這裡使用了範例資料資料夾只是為了測試它是否有效。
dt=Open("$SAMPLE_DATA/Tablet Production.jmp");
obj = Fit model(
Y( :Dissolution ),
Effects( :Mill Time),
Personality( "Standard Least Squares" ),
Emphasis( "Effect Leverage" ),
Run(:Dissolution )) ;
// Extract slope and intercept
reportObj = obj << Report;
paramTable = ReportObj["Response Dissolution","Whole Model","Parameter Estimates",TableBox(1)]; //Change the report to target the table that needs saving
/*In the old method you had, you could instead make param table this to target the specific estimate column, just change the Y name:
paramTable = reportObj["Response Dissolution","Whole Model","Parameter Estimates",NumberColBox("Estimate")];*/
// Extract values from Parameter Estimates table
/*intercept = paramTable[1]; //1st column - grab the first item [corrected from what you had]
slope = paramTable[2]; //2nd column - grab the second item*/
dtnew=paramTable<<MAKE into="" data="https://community.jmp.com/" table=""></MAKE>回覆:需要從線性最小二乘模型擬合的參數估計表中提取斜率和截距並保存到文件中謝謝本。
我收到此錯誤:

回覆:需要從線性最小二乘模型擬合的參數估計表中提取斜率和截距並保存到文件中
相同的程式碼對我有用
dt=Open("$SAMPLE_DATA/Tablet Production.jmp");
obj = Fit model(Y( :Dissolution ),Effects( :Mill Time),Personality( "Standard Least Squares" ),Emphasis( "Effect Leverage" ),Run(:Dissolution )) ;
rpt=obj<<REPORT></REPORT>
<P>可能是您使用的是舊版的 JMP?<BR />也許可以嘗試使用不同的平台</P>
<BR />
<P>用 X 擬合 y</P>
<CODE class=" language-jsl">Names Default To Here( 1 );
rpt = New Window( "Tablet Production - Fit Y by X of Dissolution by Mill Time",
Data Table( "Tablet Production.jmp" ) <<
Bivariate(Y( :Dissolution ),X( :Mill Time ),
Fit Line( {Line Color( {230, 159, 0} )} )
)
);
rpt["Bivariate Fit of Dissolution By Mill Time", "Linear Fit", "Parameter Estimates",
Table Box( 1 )] << Make Into Data Table;
或者這個
擬合曲線
Names Default To Here( 1 );
rpt = New Window( "Tablet Production - Fit Curve of Dissolution by Mill Time",
Data Table( "Tablet Production.jmp" ) <<
Fit Curve( Y( :Dissolution ), X( :Mill Time ), Fit Linear ));
rpt["Fit Curve", "Linear", "Parameter Estimates", Table Box( 1 )] <<
Make Into Data Table;
回覆:需要從線性最小二乘模型擬合的參數估計表中提取斜率和截距並保存到文件中在尋找參考時,我會考慮做的一個小改變是從第一個大綱框參考中刪除列名(在本例中為「溶解」),因為它使其更加健壯。您可以忽略該輪廓框或使用通配符“?”代替柱子
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Drug.jmp");
fm = dt << Fit Model(
Y(:y),
Effects(:Drug, :x),
Personality(Standard Least Squares),
Run Model()
);
rep = Report(fm);
// tb_param_estimates1 = rep["Whole Model", "Parameter Estimates", TableBox(1)];
tb_param_estimates2 = rep["Response ?", "Whole Model", "Parameter Estimates", TableBox(1)];
通常我也會在那裡添加那些輪廓框,但這只是個人偏好
rep[OutlineBox("Response ?"), OutlineBox("Whole Model"), OutlineBox("Parameter Estimates"), TableBox(1)];回覆:需要從線性最小二乘模型擬合的參數估計表中提取斜率和截距並保存到文件中非常感謝!
回覆:需要從線性最小二乘模型擬合的參數估計表中提取斜率和截距並保存到文件中謝謝你 Jarmo! !非常感謝!