Learn R Programming

ptycho (version 1.1-4)

createOrthogonalX: Create Design Matrix With Orthogonal Columns

Description

Create a design matrix whose columns are orthogonal to each other.

Usage

createOrthogonalX(n, p)

Arguments

n
Number of rows in $X$
p
Number of columns in $X$

Value

Matrix with n rows, p columns, and column names X1, X2, and so forth.

Details

First create $X = (I_p I_p ... I_p)^T,$ where $I_p$, the identity matrix of size $p$, is repeated ceiling(n/p) times. If p does not divide n, remove rows at the bottom so that $X$ has n rows. Divide by the root mean square of the columns of $X$.

See Also

createData

Examples

Run this code
n <- 50; p <- 5
X <- createOrthogonalX(n, p)
XtX <- t(X) %*% X
D <- diag(n-1, nrow=p)
# XtX and D are not quite equal due to roundoff error
range(XtX - D)

Run the code above in your browser using DataLab