createOrthogonalX: Create Design Matrix With Orthogonal Columns

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/lib.R

Description

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

Usage

1

Arguments

n

Number of rows in X

p

Number of columns in X

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.

Value

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

Author(s)

Laurel Stell and Chiara Sabatti
Maintainer: Laurel Stell <lstell@stanford.edu>

See Also

createData

Examples

1
2
3
4
5
6
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)

Example output

[1] -7.105427e-15  0.000000e+00

ptycho documentation built on May 2, 2019, 9:45 a.m.