Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Re: Need coefficients for equation

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Sep 6, 2019 4:09 PM
(1947 views)

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

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Created:
Sep 6, 2019 5:33 PM
| Last Modified: Sep 6, 2019 5:43 PM
(1936 views)
| Posted in reply to message from raj138 09-06-2019

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

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Created:
Sep 6, 2019 5:33 PM
| Last Modified: Sep 6, 2019 5:43 PM
(1937 views)
| Posted in reply to message from raj138 09-06-2019

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";
```

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Need coefficients for equation

Hi @gzmorgan0

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
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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);
```

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Need coefficients for equation

Additional solutions:

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!

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Need coefficients for equation

**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.

Article Labels

There are no labels assigned to this post.