* * Example 3.3 from page 75 * data(unit=input,org=columns) 1 5 y x1 x2 x3 3 1 3 5 1 1 1 4 8 1 5 6 3 1 2 4 5 1 4 6 * * The CMOM instruction computes cross product matrices. By including y and the * three x variables, we have y'y, X'y and X'X, all in a single matrix. We can * then use the %xsubmat function to pull out the pieces we need. * cmom # y x1 x2 x3 compute xx=%xsubmat(%cmom,2,4,2,4) compute xy=%xsubmat(%cmom,1,1,2,4) compute b=%solve(xx,xy) * * And the (1,1) element of the cross product matrix is y'y, which we need to * compute the sum of squared residuals * compute rss=%cmom(1,1)-%dot(b,xy) disp "Multiple Regression Coefficients" b disp "Sum of Squared Residuals" rss * * Same thing with means extracted. This is done using the "center" option on * cmom. Of course, we leave the "x1" variable out of X when we do that. * cmom(center) # y x2 x3 compute xx=%xsubmat(%cmom,2,3,2,3) compute xy=%xsubmat(%cmom,1,1,2,3) compute b=%solve(xx,xy) disp "Multiple Regression Coefficients-Deviation Form" b