Learn R Programming

alr3 (version 2.0.5)

randomLinComb: Compute a random linear combination of the columns of a matrix or data frame

Description

Computes $Xa$ where $X$ is an $n by p$ matrix, and $a$ is a random vector of length $p$.

Usage

randomLinComb(X, seed = NULL)
"randomLinComb" (X, seed=NULL)

Arguments

X
An $n by p$ matrix or data frame. For the lm method, X is a linear regression model, and randomLinComb is applied to model.matrix(X)
seed
If not NULL, use this to initialize the random number generator

Value

A vector of length $n$.

Details

The matrix $X$ is first scaled and centered. $a$ is computed to have random uniform components on $(-1,1)$.

See Also

pure.error.anova

Examples

Run this code
randomLinComb(matrix(rnorm(9),ncol=3))

Run the code above in your browser using DataLab