Description Usage Arguments Details Value Author(s) See Also Examples
gsorth
uses sequential, orthogonal projections, as
in the Gram-Schmidt method, to transform a matrix or numeric
columns of a data frame into an uncorrelated set, possibly
retaining the same column means and standard deviations as the original.
In statistical applications, interpretation depends on
the order
of the variables orthogonalized.
In multivariate linear models, orthogonalizing the response, Y variables
provides the equivalent of step-down tests, where Y1 is tested alone,
and then Y2.1, Y3.12, etc. can be tested to determine their
additional contributions over the previous response variables.
Similarly, orthogonalizing the model X variables provides the
equivalent of Type I tests, such as provided by anova
.
1 |
y |
A numeric data frame or matrix |
order |
An integer vector specifying the order of and/or a subset of
the columns of |
recenter |
If |
rescale |
If |
adjnames |
If |
The method is equivalent to setting each of columns 2:p
to
the residuals from a linear regression of that column on all prior
columns, i.e.,
z[,j] <- resid( lm( z[,j] ~ as.matrix(z[,1:(j-1)]), data=z) )
However, for accuracy and speed the transformation is carried out using the QR decomposition.
Returns a matrix or data frame with uncorrelated columns. Row and column names are copied to the result.
Michael Friendly
qr
,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | GSiris <- gsorth(iris[,1:4])
GSiris <- gsorth(iris, order=1:4) # same, using order
str(GSiris)
zapsmall(cor(GSiris))
colMeans(GSiris)
# sd(GSiris) -- sd(<matrix>) now deprecated
apply(GSiris, 2, sd)
# orthogonalize Y side
GSiris <- data.frame(gsorth(iris[,1:4]), Species=iris$Species)
iris.mod1 <- lm(as.matrix(GSiris[,1:4]) ~ Species, data=GSiris)
Anova(iris.mod1)
# orthogonalize X side
rohwer.mod <- lm(cbind(SAT, PPVT, Raven) ~ n + s + ns + na + ss, data=Rohwer)
Anova(rohwer.mod)
# type I tests for Rohwer data
Rohwer.orth <- cbind(Rohwer[,1:5], gsorth(Rohwer[, c("n", "s", "ns", "na", "ss")], adjnames=FALSE))
rohwer.mod1 <- lm(cbind(SAT, PPVT, Raven) ~ n + s + ns + na + ss, data=Rohwer.orth)
Anova(rohwer.mod1)
# compare with anova()
anova(rohwer.mod1)
# compare heplots for original Xs and orthogonalized, Type I
heplot(rohwer.mod)
heplot(rohwer.mod1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.