BookmarkSubscribe
Choose Language Hide Translation Bar

## Need coefficients for equation

Hello,

I need to generate the coefficients for the fit equation between 2 variables. However JMP generates equations by modifying the independent variable, which is not what I want. Is there anything that can be done to avoid JMP in doing so?

For example, for the below table, JMP generates this equation, "Y = 1124.1 - 38.7*X + 9.8*(X-23)^2 + 0.7*(X-23)^3 - 0.1*(X-23)^4".

What I want is just A*X^4 + B*X^3 + C*X^2 + D*X + E. How do I get it in this form?

 X Y 12 111 13 213 16 654 23 222 33 877 41 94

1 ACCEPTED SOLUTION

Accepted Solutions

## Re: Need coefficients for equation

If you are using the JMP UI and using JMP Fit Y by X, then select Fit Special and the dialog window below will appear:

• uncheck Centered Polynomial
• Select Quartic for a 4th order polynomial  If you are scripting there are numerous methods to get this, here is one example

``````Names Default to Here(1);

dt = New Table( "Coef Example",
Add Rows( 6 ),
New Column( "X",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [12, 13, 16, 23, 33, 41] )
),
New Column( "Y",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [111, 213, 654, 222, 877, 94] )
)
);

biv = dt <<Bivariate(
Y( :Y ),
X( :X ),
Fit Special(
Degree( 4 ),
Centered Polynomial( 0 )
)
);
coef_vec = Report(biv )["Parameter Estimates"][NumberColBox(1)] << Get as Matrix;
eqn_txt  = Report(biv )["Polynomial Fit Degree=4"][TextBox(1)] << get text;

show(coef_vec, eqn_txt);
/*:

coef_vec = [-19170.6096344096, 3588.21966043696, -233.095589066526, 6.37271344368134, -0.0620122936283627];
eqn_txt = "Y = -19170.61 + 3588.2197*X - 233.09559*X^2 + 6.3727134*X^3 - 0.0620123*X^4";``````

5 REPLIES 5

## Re: Need coefficients for equation

If you are using the JMP UI and using JMP Fit Y by X, then select Fit Special and the dialog window below will appear:

• uncheck Centered Polynomial
• Select Quartic for a 4th order polynomial  If you are scripting there are numerous methods to get this, here is one example

``````Names Default to Here(1);

dt = New Table( "Coef Example",
Add Rows( 6 ),
New Column( "X",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [12, 13, 16, 23, 33, 41] )
),
New Column( "Y",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [111, 213, 654, 222, 877, 94] )
)
);

biv = dt <<Bivariate(
Y( :Y ),
X( :X ),
Fit Special(
Degree( 4 ),
Centered Polynomial( 0 )
)
);
coef_vec = Report(biv )["Parameter Estimates"][NumberColBox(1)] << Get as Matrix;
eqn_txt  = Report(biv )["Polynomial Fit Degree=4"][TextBox(1)] << get text;

show(coef_vec, eqn_txt);
/*:

coef_vec = [-19170.6096344096, 3588.21966043696, -233.095589066526, 6.37271344368134, -0.0620122936283627];
eqn_txt = "Y = -19170.61 + 3588.2197*X - 233.09559*X^2 + 6.3727134*X^3 - 0.0620123*X^4";``````

## Re: Need coefficients for equation

Thank you for the solution. Sometimes, I have to fit using polynomial of degree 6 in which case your solution 1 does not work for me. I have option to fit only until degree 5.

I like your solution 2 using scripting but could you please help modify the script to call the data from the table rather than mention the values in the code, because sometimes i get data with 100s of rows.

-Raj

Highlighted

## Re: Need coefficients for equation

There are multiple methods to reference a data table and specify the column names.  The JMP  Menu > Help > Scripting Index and  JMP Menu > Help > Books > Scripting Guide are excellent references.

A common method to refer to the curretly open data table is

``dt = Current Data Table();``

When you want to open a data table the syntax is

``dt = Open( "directory/file.jmp" );``

JMP can also get data drom a datbase and other file types, like Excel. Below is an example using the sample dattaset Big Class.jm with weight for Y and height for X. Note with a script you can specify a higher order polynomial.

``````Names Default to Here(1);

dt = Open("\$Sample_Data/Big Class.jmp");
biv = dt <<Bivariate(
Y( :weight ),
X( :height ),
Fit Special(
Degree( 6 ),
Centered Polynomial( 0 )
)
);
coef_vec = Report(biv )["Parameter Estimates"][NumberColBox(1)] << Get as Matrix;
eqn_txt  = Report(biv )["Polynomial Fit Degree=?"][TextBox(1)] << get text;

show(coef_vec, eqn_txt);
``````

## Re: Need coefficients for equation

If you use Fit Model, click the red triangle in the top left corner of the launch dialog and de-select Center Polynomials.

If you saves the fitted centered model as a column formula, open the formula in the Formula Editor, click the red triangle above the formula and select Simplify.

Learn it once, use it forever!

## Re: Need coefficients for equation

Hi Mark. Just a quick additional note to the readers, that Save Predicted for Fit Y by X, centered Polynomial, quartic, saves the centered model. However, it is the power formula vs. nested multiplication formula saved by Fit Model. Simplify does not expand and simplify the power formula, and as you stated in your post, Simplify will create the uncenterd formula from the nested multiplication formula. Fit Y by X saved power formula Fit Model saved nested multiplication formula