resid = Y - X * beta; // the residuals, Y - predicted
sse = resid` * resid; // sum of squared errors
Show( beta, sse );
xpxi = Inv( x` * x );
beta = xpxi * x` * y; // parameter estimates
resid = y - x * beta; // residuals
sse = resid` * resid; // sum of squared errors
mse = sse / dfe; // mean square error, error variance estimate
alpha = .05;
betau95 = beta + qt * stdb; // upper 95% confidence limits
betal95 = beta - qt * stdb; // lower 95% confidence limits
tratio = beta :/ stdb; // Student's T ratios
New Window( "Big Class Regression",
•
|
Y is a vector of responses
|
•
|
a is the intercept term
|
•
|
b is a vector of coefficients
|
•
|
X is a design matrix for the factor
|
•
|
e is an error term
|
Design Nom( factor );
Next, add a column of 1s to the design matrix for the intercept term. You can do this by concatenating J and Design Nom(), as follows:
Now, to solve the normal equation, you need to construct a matrix M with partitions:
You can construct matrix M in one step by concatenating the pieces, as follows:
Now, sweep M over all the columns in X’X for the full fit model, and over the first column only for the intercept-only model:
•
|
You could modify this into a generalized ANOVA script by replacing some of the explicit values in the script with arguments. These results match those from the Fit Model platform. See 图 7.1.
Construct the report in 图 7.1 as follows:
2.
|
obj = Fit Model(
Personality( "Standard Least Squares" ),
3.
|
ranova = obj << Report;