normalize: Normalize data

Description Usage Arguments Details Examples

Description

Normalize each column of the object using different methods. See details.

Usage

1
2
3
4
5
6
7
normalize(x, ...)

## Default S3 method:
normalize(x, method = "sd1", base.period = 1:nrow(x), ...)

## S3 method for class 'zoo'
normalize(x, method = "sd1", base.period = index(x), ...)

Arguments

x

a vector, matrix, data frame or zoo object.

...

additional arguments to be passed to or from methods.

method

a character string indicating which method to use. Must be 'sd1'(default), 'anomaly' or 'perc'. See details.

base.period

a vector indicating the index or range of the base period. If NULL, base period is the all index range. For matrix, base.period means the row numbers.

Details

Three methods for normalization can be used:

  1. "anomaly": Each column is normalized by x - μ, where μ is the mean value based on the base.period.

  2. "perc": Each column is normalized by 100 (x - μ) / μ. This is often called anomaly percentage.

  3. "sd1": Each column is normalized by (x - μ) / σ, where σ is the standard deviation based on the base.period. The standard deviations of the results will be 1 if the base.period is set to be the whole time range.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
x <- matrix(1 : 20, nrow = 10)
colnames(x) <- c('a', 'b')
rownames(x) <- 1 : 10
normalize(x, method = 'anomaly')
normalize(x, method = 'perc')
normalize(x, method = 'sd1')

z <- zoo(x, order.by = 1991 : 2010)
normalize(z)

x <- matrix(1 : 20, nrow = 5)
colAttr <- data.frame(month = c(2, 3, 5, 6), name = c(rep('xxx', 3), 'yyy'))
zc <- zoocat(x, order.by = 1991 : 1995, colattr = colAttr)
normalize(zc)

zoocat documentation built on May 2, 2019, 10:22 a.m.