proj: Projections of Models

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

proj returns a matrix or list of matrices giving the projections of the data onto the terms of a linear model. It is most frequently used for aov models.

Usage

 1 2 3 4 5 6 7 8 9 10 11 12 13 proj(object, ...) ## S3 method for class 'aov' proj(object, onedf = FALSE, unweighted.scale = FALSE, ...) ## S3 method for class 'aovlist' proj(object, onedf = FALSE, unweighted.scale = FALSE, ...) ## Default S3 method: proj(object, onedf = TRUE, ...) ## S3 method for class 'lm' proj(object, onedf = FALSE, unweighted.scale = FALSE, ...)

Arguments

 object An object of class "lm" or a class inheriting from it, or an object with a similar structure including in particular components qr and effects. onedf A logical flag. If TRUE, a projection is returned for all the columns of the model matrix. If FALSE, the single-column projections are collapsed by terms of the model (as represented in the analysis of variance table). unweighted.scale If the fit producing object used weights, this determines if the projections correspond to weighted or unweighted observations. ... Swallow and ignore any other arguments.

Details

A projection is given for each stratum of the object, so for aov models with an Error term the result is a list of projections.

Value

A projection matrix or (for multi-stratum objects) a list of projection matrices.

Each projection is a matrix with a row for each observations and either a column for each term (onedf = FALSE) or for each coefficient (onedf = TRUE). Projection matrices from the default method have orthogonal columns representing the projection of the response onto the column space of the Q matrix from the QR decomposition. The fitted values are the sum of the projections, and the sum of squares for each column is the reduction in sum of squares from fitting that column (after those to the left of it).

The methods for lm and aov models add a column to the projection matrix giving the residuals (the projection of the data onto the orthogonal complement of the model space).

Strictly, when onedf = FALSE the result is not a projection, but the columns represent sums of projections onto the columns of the model matrix corresponding to that term. In this case the matrix does not depend on the coding used.

Author(s)

The design was inspired by the S function of the same name described in Chambers et al (1992).

References

Chambers, J. M., Freeny, A and Heiberger, R. M. (1992) Analysis of variance; designed experiments. Chapter 5 of Statistical Models in S eds J. M. Chambers and T. J. Hastie, Wadsworth & Brooks/Cole.