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
- :
- Discussions
- :
- Re: Using Matrix Math instead of Fit Model

Topic Options

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

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

2 weeks ago
(159 views)

Hi,

I've been trying to script a quadratic fit using a matrix instead of fit model. This might just be my lack of understanding of matrix math...but I don't how JMP is fitting my data. For the following Variables X and Y, I want to fit the data using

X, X*X, and Y

The fit model module gives me the following output:

22.4221618758449 + 0.0545925476534461 * :Y + (:X - 6.51578947368421) * ((:X

-6.51578947368421) * -0.0568980754963725) + -0.0988212800731804 * :X

My first question is what is Fit Model doing that's leading to the -6.515789 transformation of X^2? (vs just using the squared values of the X column)

I guess my second question would be if I wanted to adapt the matrix fit to it, why is it outputing the same parameters for X^2 and Y..even though I didn't transform my X^2 with that -.651589 term?

Output of thte code below:

Intercept =20.006524922

X=0.6426504827

Y=0.0545925477

X^2=-0.056898075 1

Thanks for any insight on why fit model isn't matching the matrix math... thanks

```
xVals2=Column(dt,"X")<<getasmatrix;
xVals3=Column(dt,"Y")<<getasmatrix;
XVals4=Column(dt,"X^2")<<getasmatrix;
xVals=xVals2||xVals3||xVals4;
yVals = Column(dt, "Output") << getAsMatrix;
groupID = Column(dt, "Group") << getAsMatrix;
ng=col max(:Group);
// (2) Add the unit vector to the design matrix
xVals = J(NRow(xVals), 1, 1)||xVals;
// (3) Do the linear regression for each group and store the results
beta = J(ng, 4, .);
for (g=1, g <= ng, g++,
thisGroup = Loc(groupID == g);
beta[g, 0] = Transpose(Inv(xVals[thisGroup, 0]`*xVals[thisGroup, 0])*xVals[thisGroup, 0]`*yVals[thisGroup]);
);
```

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

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

2 weeks ago
(282 views)

Solution

JMP is centering the X^2 term (subtracting the mean of X from the values of X) before squaring. This is a common technique used with quadratic terms because it can dramatically reduce the correlation of X and X^2. It doesn't change the parameter estimate, but it does decrease the standard error for the X^2 parameter estimate. That means it will be easier to detect significant curvature.

This transformation does change the intercept value, as well as its interpretation. If you do some algebra and FOIL the (X-Xbar)*(X-Xbar)*beta2 part of the model, the Fit Model result will match yours. The models will produce the same prediction.

-- Cameron Willden

1 REPLY

Highlighted
Solution

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

2 weeks ago
(283 views)

JMP is centering the X^2 term (subtracting the mean of X from the values of X) before squaring. This is a common technique used with quadratic terms because it can dramatically reduce the correlation of X and X^2. It doesn't change the parameter estimate, but it does decrease the standard error for the X^2 parameter estimate. That means it will be easier to detect significant curvature.

This transformation does change the intercept value, as well as its interpretation. If you do some algebra and FOIL the (X-Xbar)*(X-Xbar)*beta2 part of the model, the Fit Model result will match yours. The models will produce the same prediction.

-- Cameron Willden