Projection Matrix

DESCRIPTION:
Returns a matrix or series of matrices that represent the projection.

This function is generic (see Methods); method functions can be written to handle specific classes of data. Classes which already have methods for this function include: aovlist, lm.


USAGE:
proj(object, onedf=T)

REQUIRED ARGUMENTS:
object:
any object of class lm or any object that inherits from class lm. It will run faster if the object contains either a qr component or a proj component.

OPTIONAL ARGUMENTS:
onedf:
logical flag. When TRUE (the default for objects of class lm), the function returns a matrix of single-degree-of-freedom projections of the response variable onto the columns of the predictor matrix. The default method does not use this argument. When FALSE, an option available in proj.lm and the default for objects of class aov, the function collapses the single degree of freedom projections into multi-degree-of-freedom projections. Each column of the collapsed result represents one term of the analysis of variance table. The sum of squares of each column is the sum of squares for the corresponding term in the model formula, with degrees of freedom given by the df attribute of the result. The formula itself is returned in the formula attribute.

VALUE:
matrix of orthogonal columns, one column for each column in an orthogonalized model matrix. In the default method, each column in the result is the projection of the response variable onto a column in the Q matrix from the QR decomposition of the model matrix. The sum across the columns gives the column of predicted values. The sum of the squared values in each column is the single-degree-of-freedom sum of squares for the corresponding column of the model matrix. The onedf attribute returns the value of the onedf argument. The method for lm objects appends a column of residuals. The method for aovlist objects returns a list of projection matrices, one for each stratum in the design.

DETAILS:
If the fitted model does not contain a qr component (which defines the numeric decomposition used in the fitting), it will be necessary to refit. Therefore, if you know in advance that you want projections, it saves some time to add qr=T to the original call.

SEE ALSO:
aov , aov.genyates , lm .

EXAMPLES:
lm.object <- lm(cost ~ age + type + car.age, claims)
tmp <- proj(lm.object)

gunaov.qr <- aov(Rounds ~ Method + Physique/Team, gun, qr = T) gunaov.proj <- proj(gunaov.qr)