View source: R/utility_functions.R
zscore | R Documentation |
Removes the mean and standardizes the variance to 1.
zscore(x, mean.only = FALSE)
x |
n x T matrix of numbers |
mean.only |
If TRUE, only remove the mean. |
n = number of observation (y) time series. T = number of time steps in the time series.
The z-scored values (z) of a matrix of y values are
z_i = \Sigma^{-1}(y_i-\bar{y})
where \Sigma
is a diagonal matrix with the standard deviations of each time series (row) along the diagonal, and \bar{y}
is a vector of the means.
n x T matrix of z-scored values.
Eli Holmes, NOAA, Seattle, USA.
zscore(1:10)
x <- zscore(matrix(c(NA, rnorm(28), NA), 3, 10))
# mean is 0 and variance is 1
apply(x, 1, mean, na.rm = TRUE)
apply(x, 1, var, na.rm = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.