# stdize: Centering and scaling of matrices In ffmanova: Fifty-Fifty MANOVA

 stdize R Documentation

## Centering and scaling of matrices

### Description

Function to center and/or scale the coloumns of a matrix in various ways. The coloumns can be centered with their means or with supplied values, and they can be scaled with their standard deviations or with supplied values.

### Usage

``````stdize(x, center = TRUE, scale = TRUE, avoid.zero.divisor = FALSE)

stdize3(x, center = TRUE, scale = TRUE, avoid.zero.divisor = FALSE)
``````

### Arguments

 `x` A matrix. `center` A logical, or a numeric vector. The values to subtract from each column. If `center` is `TRUE`, the mean values are used. `scale` A lgical, or a numeric vector. The values to divide each column with. If `scale` is `TRUE`, the standard deviations are used. `avoid.zero.divisor` A logical. If `TRUE`, each occurence of `0` in `scale` is replaced with a `1`.

### Details

`stdize` standardizes the coloumns of a matrix by subtracting their means (or the supplied values) and dividing by their standard deviations (or the supplied values).

If `avoid.zero.divisor` is `TRUE`, division-by-zero is guarded against by substituting any `0` in `center` (either calculated or supplied) with `1` prior to division.

The main difference between `stdize` and `scale` is that `stdize` divides by the standard deviations even when `center` is not `TRUE`.

A matrix.

### Note

`stdize3` is a variant with a three-element list as output (`x, center, scale`) and where `avoid.zero.divisor` is also used to avoid centring (constant term in model matrix is unchanged).

### Author(s)

Bjørn-Helge Mevik and Øyvind Langsrud

`scale`

### Examples

``````
A <- matrix(rnorm(15, mean = 1), ncol = 3)
stopifnot(all.equal(stdize(A), scale(A), check.attributes = FALSE))

## These are different:
stdize(A, center = FALSE)
scale(A, center = FALSE)

``````

ffmanova documentation built on Oct. 18, 2023, 5:08 p.m.