porthogonalize.list {dae}  R Documentation 
Takes a list of projectors
and constructs a pstructure.object
that includes projectors, each of which has been orthogonalized to all projectors preceding it in the list.
Description
Constructs a pstructure.object
that includes a
set of mutually orthogonal projectors, one for each of the
projectors
in the list
.
These specify a structure, or an orthogonal decomposition of the
data space. This function externalizes the process previously performed
within pstructure.formula
to orthogonalize
projector
s. There are three methods
available for carrying out orthogonalization: differencing
,
eigenmethods
or the default hybrid
method.
It is possible to use this function to find out what sources are associated with the terms in a model and to determine the marginality between terms in the model. The marginality matrix can be saved.
Usage
## S3 method for class 'list'
porthogonalize(projectors, formula = NULL, keep.order = TRUE,
grandMean = FALSE, orthogonalize = "hybrid", labels = "sources",
marginality = NULL, check.marginality = TRUE,
omit.projectors = FALSE,
which.criteria = c("aefficiency","eefficiency","order"),
aliasing.print = TRUE, ...)
Arguments
projectors 

formula 
An object of class 
keep.order 
A 
grandMean 
A 
orthogonalize 
A 
labels 
A 
marginality 
A square The entry in the ith row and jth column will be one if the
ith term is marginal to the jth term i.e. the column space of the
ith term is a subspace of that for the jth term and so the source
for the jth term is to be made orthogonal to that for the ith term.
Otherwise, the entries are zero. A row and column should not be
included for the grand mean even if 
check.marginality 
A 
omit.projectors 
A 
which.criteria 
A character 
aliasing.print 
A 
... 
further arguments passed to 
Details
It is envisaged that the projectors
in the list
supplied to the projectors
argument correspond to the terms in a
linear model. One way to generate them is to obtain the design matrix X
for a term and then calculate its projector as
\mathbf{X(X'X)^X'}
, There are three methods available for
orhtogonalizing the supplied projectors: differencing
,
eigenmethods
or the default hybrid
method.
Differencing
relies on
comparing the factors involved in two terms, one previous to the
other, to identify whether to subtract the orthogonalized projector
for the previous term from the primary projector of the other. It
does so if factors/variables for the previous term are a subset of
the factors/variablesfor for the other term. This relies on ensuring that all
projectors whose factors/variables are a subset of the current
projector occur before it in the expanded formula. It is checked that
the set of matrices are mutually orthogonal. If they are not then
a warning is given. It may happen that differencing does not produce
a projector, in which case eigenmethods
must be used.
Eigenmethods
forces each projector to be orthogonal
to all terms previous to it in the expanded formula. It uses
equation 4.10 of James and Wilkinson (1971), which involves
calculating the canonical efficiency factors for pairs of primary
projectors. It produces a
table of efficiency criteria for partially aliased terms. Again,
the order of terms is crucial. This method has the disadvantage that
the marginality of terms is not determined and so sources names are set
to be the same as the term names, unless a marginality
matrix
is supplied.
The hybrid
method is the most general and uses the relationships
between the projection operators for the terms in the formula
to decide which projectors to subtract and which to orthogonalize using
eigenmethods. If \mathbf{Q}_i
and \mathbf{Q}_j
are
two projectors for two different terms, with i < j
, then
if
\mathbf{Q}_j\mathbf{Q}_i \neq \mathbf{0}
then have to orthogonalize\mathbf{Q}_j
to\mathbf{Q}_i
.if
\mathbf{Q}_j\mathbf{Q}_i = \mathbf{Q}_j
then, if\mathbf{Q}_i = \mathbf{Q}_j
, they are equal and\mathbf{Q}_j
will be removed from the list of terms; otherwise they are marginal and\mathbf{Q}_i
is subtracted from\mathbf{Q}_j
.if have to orthogonalize and
\mathbf{Q}_j\mathbf{Q}_i = \mathbf{Q}_i
then\mathbf{Q}_j
is aliased with previous terms and will be removed from the list of terms; otherwise\mathbf{Q}_i
is partially aliased with\mathbf{Q}_j
and\mathbf{Q}_j
is orthogonalized to\mathbf{Q}_i
using eigenmethods.
The order of projections matrices in the list
is crucial in this process.
Of the three methods, eigenmethods
is least likely to fail, but it
does not establish the marginality between the terms. It is often needed
when there is nonorthogonality between terms, such as when there are several
linear covariates. It can also be more efficeint in these circumstances.
The process can be computationally expensive, particularly for a large data set (500 or more observations) and/or when many terms are to be orthogonalized.
If the error Matrix is not idempotent
should occur then, especially
if there are many terms, one might try using set.daeTolerance
to reduce the tolerance used in determining if values are either the same
or are zero; it may be necessary to lower the tolerance to as low as 0.001.
Also, setting orthogonalize
to eigenmethods
is worth a try.
Value
Author(s)
Chris Brien
References
James, A. T. and Wilkinson, G. N. (1971) Factorization of the residual operator and canonical decomposition of nonorthogonal factors in the analysis of variance. Biometrika, 58, 279294.
See Also
pstructure.formula
, proj2.efficiency
,
proj2.combine
, proj2.eigen
,
projs.2canon
in package dae,
eigen
.
projector
for further information about this class.
Examples
## PBIBD(2) from p. 379 of Cochran and Cox (1957) Experimental Designs.
## 2nd edn Wiley, New York
PBIBD2.unit < list(Block = 6, Unit = 4)
PBIBD2.nest < list(Unit = "Block")
trt < factor(c(1,4,2,5, 2,5,3,6, 3,6,1,4, 4,1,5,2, 5,2,6,3, 6,3,4,1))
PBIBD2.lay < designRandomize(allocated = trt,
recipient = PBIBD2.unit,
nested.recipients = PBIBD2.nest)
## manually obtain projectors for units
Q.G < projector(matrix(1, nrow=24, ncol=24)/24)
Q.B < projector(fac.meanop(PBIBD2.lay$Block))
Q.BU < projector(diag(1, nrow=24))
## manually obtain projector for trt
Q.T < projector(fac.meanop(PBIBD2.lay$trt)  Q.G)
##Orthogonalize the projectors using porthogonalize.list
Qs < list(Mean = Q.G, Block = Q.B, "Block:Unit" = Q.BU)
struct < porthogonalize(Qs, grandMean = TRUE)
Qs < struct$Q
(lapply(Qs, degfree))
#Add a linear covariate
PBIBD2.lay < within(PBIBD2.lay,
{
cBlock < as.numfac(Block)
cBlock < cBlock  mean(unique(cBlock))
})
X < model.matrix(~ cBlock, data = PBIBD2.lay)
Q.cB < projector(X %*% mat.ginv(t(X) %*% X) %*% t(X))
Qs < list(cBlock = Q.cB, Block = Q.B, "Block:Unit" = Q.BU)
struct < porthogonalize(Qs, grandMean = FALSE)
Qs < struct$Q
(lapply(Qs, degfree))