Description Usage Arguments Details Value Note Author(s) Examples

Takes a matrix of data frame with covariates, adds a constant covariate (optional), and orthonormalizes the set.

1 | ```
orthonormalizeCovariates(cvrt, modelhasconstant)
``` |

`cvrt` |
A matrix or data frame with covariates (one column per covariate). |

`modelhasconstant` |
Set to |

Factor variables are split into dummy variables before orthonormalization.

The operation is performed via QR decomposition (qr).

Returns a matrix with orthogonal columns with unit length,
whose columns spans the same space as the covariates plus a constant
(if `modelhasconstant`

is `TRUE`

).

This function is used in several parts of the pipeline.

Andrey A Shabalin andrey.shabalin@gmail.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ```
# Sample matrix of covariates
covariates = data.frame(a = 1:12, b = 12:1)
# Orthonormalizing Covariates
cvrtqr = orthonormalizeCovariates(covariates, modelhasconstant = TRUE)
# Checking the results (round to ignore rounding errors)
print( round(crossprod(cvrtqr),15) )
# Stop if not orthonormal
stopifnot(all.equal( crossprod(cvrtqr), diag(ncol(cvrtqr)) ))
# Example with a factor variable
groups = data.frame(gr = c("a","a","a","b","b","b","c","c","c"))
orthonormalizeCovariates(groups)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.