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