createOrthogonalX | R Documentation |
Create a design matrix whose columns are orthogonal to each other.
createOrthogonalX(n, p)
n |
Number of rows in |
p |
Number of columns in |
First create
\hat{X} = (I_p\,\,\,I_p\,\,\,\cdots\,\,\,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 \hat{X}
has n
rows. Divide by the
root mean square of the columns of \hat{X}
.
Matrix with n
rows, p
columns, and column names X1
,
X2
, and so forth.
Laurel Stell and Chiara Sabatti
Maintainer: Laurel Stell <lstell@stanford.edu>
createData
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.