Learn R Programming

mht (version 3.1.2)

data.scale: Scale a matrix

Description

Scale the data so each column has mean 0 and variance 1. This function is used as a pre-processing step to prep the data for analysis in all functions of the mht package.

Usage

data.scale(data,warning)

Arguments

data
Input matrix of dimension n * p; each row is an observation vector. The intercept should be included in the first column as (1,...,1). If not, it is added.
warning
Logical value. A warning message is printed if the intercept is added. Default is TRUE.

Value

data
Scaled data.
intercept
Logical value. TRUE if the intercept was already included in the input data.
means.data
Vector of means of the input data matrix.
sigma.data
Vector of variances of the input data matrix.

Details

Scale the data so each column has mean 0 and variance 1. If we note x a column of the output scaled matrix -except the first one which is the intercept, we have sum(x)=0 and sum(x^2)/n=1.

References

Multiple hypotheses testing for variable selection; F. Rohart 2011

Examples

Run this code
## Not run: 
# x=matrix(rnorm(100*20),100,20)
# res=data.scale(x)
# x.scaled=res$data
# means.x=res$means.data
# sigma.x=res$sigma.data
# ## End(Not run)

Run the code above in your browser using DataLab