need to extract slope and intercept from parameter estimates table in a linear least squares model fit and save to a fileMy code is not working and I'm having trouble identifying why. Any help would be most appreciated - thanks!
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");
Automation and ScriptingRe: need to extract slope and intercept from parameter estimates table in a linear least squares model fit and save to a fileHi @learning_JSL ,
I've altered your script to take advantage of the 'make into data table' function to bring the details over, but I've also added where your challenges with the script were by changing the paramtable to target the specific estimates section of the table - if you want to find how to do this it's best to right click>properties and highlight the estimates section to find the path to the object.
I've used the sample data folder here just to test that it works.
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>Re: need to extract slope and intercept from parameter estimates table in a linear least squares model fit and save to a fileThanks Ben.
I am getting this error:

Re: need to extract slope and intercept from parameter estimates table in a linear least squares model fit and save to a file
The same code works for me
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>
It could be that you're using an older version of JMP?
maybe try using a different platform
Fit y by X
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;
or this one
Fit Curve
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;
Re: need to extract slope and intercept from parameter estimates table in a linear least squares model fit and save to a fileOne small change I would consider doing when looking for the reference, is to drop the column name from the first outline box reference ("Dissolution" in this case) as it makes it more robust. You could either ignore that outline box or you could use wildcard "?" in place of the column
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)];
Usually I also add those outlineboxes there, but its a preference
rep[OutlineBox("Response ?"), OutlineBox("Whole Model"), OutlineBox("Parameter Estimates"), TableBox(1)];Re: need to extract slope and intercept from parameter estimates table in a linear least squares model fit and save to a fileThanks so much!
Re: need to extract slope and intercept from parameter estimates table in a linear least squares model fit and save to a fileThank you Jarmo!! Most appreciated!