standard: Standardizes a design matrix

Description Usage Arguments Details Value Author(s) Examples

View source: R/standard.R

Description

The function std accepts a design matrix and returns a standardized version of that matrix (i.e., each column will have mean 0 and mean sum of squares equal to 1). The code has been adapted from the ncvreg package (Breheny and Huang, 2011).

Usage

1

Arguments

X

A matrix (or object that can be coerced to a matrix, such as a data frame).

Details

This function centers and scales each column of X so that

sum(X[,j])=0

and

sum(X[,j]^2)=n

for all j. This is usually not necessary to call directly, as SSLASSO internally standardizes the design matrix, but inspection of the standardized design matrix can sometimes be useful. This differs from the base R function scale in two ways: (1) scale uses the sample standard deviation sqrt(sum(x^2)/(n-1)), while std uses the root-mean-square, or population, standard deviation sqrt(mean(sum(x^2))), and (2) std is faster. The reason for using the population standard deviation is that SSLASSO assumes that the columns of the design matrix have been scaled to have norm sqrt(n).

Value

The standardized design matrix, with attribues "center" and "scale" corresponding to the mean and (population) standard deviation used to scale the columns.

Author(s)

Patrick Breheny

Examples

1
2
3
4
X <- matrix(rnorm(50), 10, 5)
S <- standard(X)
apply(S, 2, sum)
apply(S, 2, function(x) mean(x^2))

SSLASSO documentation built on Dec. 16, 2019, 1:37 a.m.

Related to standard in SSLASSO...