HH (version 2.2-23)

orthog.complete: Construct an orthogonal matrix which is an arbitrary completion of the column space of the input set of columns.

Description

Construct an orthogonal matrix which is an arbitrary completion of the column space of the input set of columns.

Usage

orthog.complete(x, normalize=TRUE, abs2.rows=1:nrow(x),
                Int=TRUE, drop.Int=Int)

orthog.construct(y, x, x.rows, normalize=FALSE)

Arguments

x
For orthog.complete, an n-row matrix of one or more columns. For orthog.construct, a set of contrasts for a factor.
y
matrix of coefficients specifying the linear combinations estimated. This will usually be the lmat from an S-Plus "multicomp" object or the linfct component from an R "glht" object.
normalize, abs2.rows, x.rows
The default normalizes the sum of squares of the rows in abs2.rows or x.rows to 1. The optional value normalize="abs2" scales the rows in abs2.rows or x.rows to make the
Int
logical. Default TRUE means make all columns orthogonal to the constant column (Intercept in regression terminology). The alternative is to use only the columns in the input matrix x.
drop.Int
logical. The default is to drop the constant column and to keep all columns when the constant is not automatically generated.

Value

  • Matrix of orthogonal columns.

Details

This function is based on qr.Q. The input matrix x has n rows and an arbitrary non-zero number of columns. The result is an n by n orthogonal matrix. By default the first column of the result is constant and is not returned. The second column of the result is orthogonal to the first result column. Together the first two result columns span the space of the constant column and the first input column. The third result column is orthogonal to the first two result columns and the the three result columns together span the space of the constant column and the first two inout columns. Similarly for the remaining result columns. Result columns beyond the number of input columns are constructed as an arbitrary orthogonal completion. If the input columns are orthogonal to each other and to the constant column, then the result columns are rescaled versions of the input columns. Optionally (drop.Int=FALSE), the constant column can be returned. By default the columns are scaled to have sum of squares equal 1. If normalize="abs2", they are scaled to make the sum of all positive value equal 1 and the sum of all negative values equal -1. Together, the sum of the absolute values of each column is 2. If the input is a set of columns from a contrast matrix for a design that has multiple terms, the abs2.rows argument is used to specify which rows are to be included in the normalization. These will normally be rows associated with one of the main effects.

References

Heiberger, Richard M. and Holland, Burt (2004b). Statistical Analysis and Data Display: An Intermediate Course with Examples in S-Plus, R, and SAS. Springer Texts in Statistics. Springer. ISBN 0-387-40270-5.

See Also

MMC

Examples

Run this code
zapsmall(
orthog.complete(cbind("4-12"=c(-1,-1, 0, 2),
                      "1-2" =c( 1,-1, 0, 0)))
)

zapsmall(
orthog.complete(cbind("4-12"=c(-1,-1, 0, 2),
                      "1-2" =c( 1,-1, 0, 0)),
                drop.Int=FALSE)
)

zapsmall(
orthog.complete(cbind("4-12"=c(-1,-1, 0, 2),
                      "1-2" =c( 1,-1, 0, 0)),
                normalize="abs2")
)


## used in MMC plots
tmp <- data.frame(y=rnorm(12),
                  a=factor(c("u","u","u","u",
                             "v","v","v","v",
                             "w","w","w","w")))
tmp.aov <- aov(y ~ a, data=tmp)
lmat <- if.R(
  s=multicomp(tmp.aov, focus="a")$lmat,
  r={lmat.reduced <- t(glht(tmp.aov, linfct=mcp(a="Tukey"))$linfct)
     rbind(lmat.reduced, AU=-apply(lmat.reduced[-1,], 2, sum))
    })
zapsmall(lmat)

lmat.complete <- orthog.complete(lmat, abs2.rows=-1,
                                 normalize="abs2",
                                 drop.Int=FALSE)[,1:3]
zapsmall(lmat.complete)
if.R(r=zapsmall(lmat.complete[-4,]),
     s={})

Run the code above in your browser using DataCamp Workspace