swp | R Documentation |
The swp
function “sweeps” a matrix on the rows and columns given in index
to produce a new matrix
with those rows and columns “partialled out” by orthogonalization. This was defined as a fundamental statistical operation in
multivariate methods by Beaton (1964) and expanded by Dempster (1969). It is closely related to orthogonal projection,
but applied to a cross-products or covariance matrix, rather than to data.
swp(M, index)
M |
a numeric matrix |
index |
a numeric vector indicating the rows/columns to be swept. The entries must be less than or equal
to the number or rows or columns in |
If M
is the partitioned matrix
\left[ \begin{array}{cc} \mathbf {R} & \mathbf {S} \\ \mathbf {T} & \mathbf {U} \end{array} \right]
where R
is q \times q
then swp(M, 1:q)
gives
\left[ \begin{array}{cc} \mathbf {R}^{-1} & \mathbf {R}^{-1}\mathbf {S} \\ -\mathbf {TR}^{-1} & \mathbf {U}-\mathbf {TR}^{-1}\mathbf {S} \\ \end{array} \right]
the matrix M
with rows and columns in indices
swept.
Beaton, A. E. (1964), The Use of Special Matrix Operations in Statistical Calculus, Princeton, NJ: Educational Testing Service.
Dempster, A. P. (1969) Elements of Continuous Multivariate Analysis. Addison-Wesley, Reading, Mass.
Proj
, QR
data(therapy)
mod3 <- lm(therapy ~ perstest + IE + sex, data=therapy)
X <- model.matrix(mod3)
XY <- cbind(X, therapy=therapy$therapy)
XY
M <- crossprod(XY)
swp(M, 1)
swp(M, 1:2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.