Choose Language Hide Translation Bar
Highlighted
Community Trekker

## JMP 7: Convert slope and intercept from regression analysis to table variables

How can I extract the slope and the intercept coming from a linear least squares model to a table variable? I want to use both values for additional calculations.

Thanks,

Helge

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User

## JMP 7: Convert slope and intercept from regression analysis to table variables

I assume you want a scripting solution. One way to do it is extract the numbers numbercolbox in the display tree that holds the parameter estimates. In the Fit Model report it is the first numeric column in the "Parameter Estimates" outline box. Below is an jsl example. I don't have access to JMP7, but it works in JMP9.

dt = Open( "\$ENGLISH_SAMPLE_DATA/Big Class.jmp" );

ls_fit = Fit Model(

Y( :weight ),

Effects( :height ),

Personality( Standard Least Squares ),

Emphasis( Effect Leverage ),

Run(

:weight << {Plot Actual by Predicted( 1 ), Plot Residual by Predicted( 1 ),

Plot Effect Leverage( 1 )}

)

);

intercept = Report( ls_fit )["Parameter Estimates"][Number Col Box( 1 )][1];

slope = Report( ls_fit )["Parameter Estimates"][Number Col Box( 1 )][2];

dt << new table variable( "intercept", intercept );

dt << new table variable( "slope", slope );

7 REPLIES 7
Highlighted
Super User

## JMP 7: Convert slope and intercept from regression analysis to table variables

I assume you want a scripting solution. One way to do it is extract the numbers numbercolbox in the display tree that holds the parameter estimates. In the Fit Model report it is the first numeric column in the "Parameter Estimates" outline box. Below is an jsl example. I don't have access to JMP7, but it works in JMP9.

dt = Open( "\$ENGLISH_SAMPLE_DATA/Big Class.jmp" );

ls_fit = Fit Model(

Y( :weight ),

Effects( :height ),

Personality( Standard Least Squares ),

Emphasis( Effect Leverage ),

Run(

:weight << {Plot Actual by Predicted( 1 ), Plot Residual by Predicted( 1 ),

Plot Effect Leverage( 1 )}

)

);

intercept = Report( ls_fit )["Parameter Estimates"][Number Col Box( 1 )][1];

slope = Report( ls_fit )["Parameter Estimates"][Number Col Box( 1 )][2];

dt << new table variable( "intercept", intercept );

dt << new table variable( "slope", slope );

Highlighted
Community Trekker

## JMP 7: Convert slope and intercept from regression analysis to table variables

Many thanks for this fast answer, but I fear that JMP7 does not support this kind of solution. I get this error message:

Can't subscript Display Box in access or evaluation of 'Subscript' , Report( ls_fit )["Parameter Estimates"]

Highlighted
Super User

## JMP 7: Convert slope and intercept from regression analysis to table variables

Ok, maybe there has been som changes in the tree structure. But I don't think you woud have to upgrade only to solve this problem (altough JMP 9 is a compelling upgrade for other reasons).

Try to replace the lines for intercept and slope in the above code with:

intercept = Report( ls_fit )[Outline Box( "Parameter Estimates" )][Number Col Box( 1 )][1];

slope = Report( ls_fit )[Outline Box( "Parameter Estimates" )][Number Col Box( 1 )][2];

Highlighted
Community Trekker

## JMP 7: Convert slope and intercept from regression analysis to table variables

Unfortunately, this doesnt work neither.

Get the same error message as before:

Can't subscript Display Box in access or evaluation of 'Subscript', Report ( ls_fit) ["Parameter Estimates"]

[/*###*/"Parameter Estimates"][....

Community Trekker

## JMP 7: Convert slope and intercept from regression analysis to table variables

After including a

show properties (ls_fit)

into the script, it becomes clear from the output that the individual items in the report are not listed as scriptable.

The samples given in the current JMP scripting guide do not work either.

I therefore assume that version 7 is not able to access the values inside the Parameter Estimates.  I have to install version 9.

Highlighted
Community Trekker

## JMP 7: Convert slope and intercept from regression analysis to table variables

I don't know if I really understand your problem, but after a linear fit (also any other) in a scatter plot you get a table with parameter estimtes. I can right-click on the table an chose "make into table" which makes a new JMP table.

Highlighted
Community Trekker

## JMP 7: Convert slope and intercept from regression analysis to table variables

Meanwhile I updated to JMP 9 and got my problem fixed. The script I use is:

//____________________________________________________________________

dt = currentDataTable ();

ls_fit = Bivariate(

Y( :Tau ),

X( :Name( "Concentration in g/mL" ) ),

Fit Line( {Line Color( "Red" )} ),

SendToReport( Dispatch( {}, "Bivar Plot", FrameBox, Frame Size( 250, 250 ) ) )

);

Intercept = Report( ls_fit )["Parameter Estimates"][Number Col Box ("Estimate")][1];

Slope = Report( ls_fit )["Parameter Estimates"][Number Col Box("Estimate")][2];

// The variables exist already in the table.

dt << set table variable( "Intercept", char (Intercept) );

dt << set table variable( "Slope", char (Slope) );

//_________________________________________________________________________

Thus,  the first answer by MS was already the solution to my problem (except for the fact that I had to include the "char" statement).

Now I can use the slope and the intercept in a quite complicated equation to calculate automatically the parameter I want to have (particle size in this case).

Thanks to all who helped!