# gsorth {heplots}

### Description

`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`

.

### Usage

gsorth(y, order, recenter = TRUE, rescale = TRUE, adjnames = TRUE)

### Arguments

- y
- A numeric data frame or matrix
- order
- An integer vector specifying the order of and/or a subset of the columns of
`y`

to be orthogonalized. If missing,`order=1:p`

where`p=ncol(y)`

. - recenter
- If
`TRUE`

, the result has same column means as original; else means = 0 for cols`2:p`

. - rescale
- If
`TRUE`

, the result has same column standard deviations as original; else sd = residual variance for cols`2:p`

- adjnames
- If
`TRUE`

, the column names of the result are adjusted to the form Y1, Y2.1, Y3.12, by adding the suffixes '.1', '.12', etc. to the original column names.

### Details

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.

### Values

Returns a matrix or data frame with uncorrelated columns. Row and column names are copied to the result.

### See Also

`qr`

,

### Examples

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)

Documentation reproduced from package heplots, version 1.0-11. License: GPL (>= 2)