需要从线性最小二乘模型拟合的参数估计表中提取斜率和截距并保存到文件中我的代码无法正常工作,但我不知道原因。如能得到任何帮助我将不胜感激 - 谢谢!
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;
回复:需要从线性最小二乘模型拟合的参数估计表中提取斜率和截距并保存到文件中在查找参考时,我会考虑做的一个小改动是从第一个大纲框参考中删除列名称(在本例中为“Dissolution”),因为它会使其更加健壮。您可以忽略该大纲框,也可以使用通配符“?”代替列
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!!非常感谢!