Learn R Programming

alr3 (version 1.1.12)

random.lin.comb: Compute a random linear combination of the columns of a matrix or data frame

Description

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

Usage

random.lin.comb(X, seed = NULL)

## S3 method for class 'lm':
random.lin.comb(X, seed=NULL)

Arguments

X
An $n \times p$ matrix or data frame. For the lm method, X is a linear regression model, and random.lin.comb 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
random.lin.comb(matrix(rnorm(9),ncol=3))

Run the code above in your browser using DataLab