topic Re: Using Matrix Math instead of Fit Model in Discussions
https://community.jmp.com/t5/Discussions/Using-Matrix-Math-instead-of-Fit-Model/m-p/59393#M32591
<P>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.</P><P>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.</P>Tue, 05 Jun 2018 22:04:44 GMTcwillden2018-06-05T22:04:44ZUsing Matrix Math instead of Fit Model
https://community.jmp.com/t5/Discussions/Using-Matrix-Math-instead-of-Fit-Model/m-p/59389#M32588
<P>Hi,</P><P> 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</P><P> </P><P>X, X*X, and Y</P><P> </P><P>The fit model module gives me the following output:</P><P>22.4221618758449 + 0.0545925476534461 * :Y + (:X - 6.51578947368421) * ((:X<BR />-6.51578947368421) * -0.0568980754963725) + -0.0988212800731804 * :X</P><P> </P><P>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)</P><P> </P><P>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?</P><P> </P><P>Output of thte code below:</P><P> </P><P>Intercept =20.006524922</P><P>X=0.6426504827</P><P>Y=0.0545925477</P><P>X^2=-0.056898075 1</P><P> </P><P> </P><P>Thanks for any insight on why fit model isn't matching the matrix math... thanks</P><PRE><CODE class=" language-jsl">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]);
);</CODE></PRE>Tue, 05 Jun 2018 21:10:46 GMThttps://community.jmp.com/t5/Discussions/Using-Matrix-Math-instead-of-Fit-Model/m-p/59389#M32588DL7232018-06-05T21:10:46ZRe: Using Matrix Math instead of Fit Model
https://community.jmp.com/t5/Discussions/Using-Matrix-Math-instead-of-Fit-Model/m-p/59393#M32591
<P>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.</P><P>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.</P>Tue, 05 Jun 2018 22:04:44 GMThttps://community.jmp.com/t5/Discussions/Using-Matrix-Math-instead-of-Fit-Model/m-p/59393#M32591cwillden2018-06-05T22:04:44Z