Removes the mean and standardizes the variance to 1.
Usage
zscore(x)
Arguments
x
n x T matrix of numbers
Value
n x T matrix of z-scored values.
Details
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.
# NOT RUN {zscore(1:10)
x <- zscore(matrix(c(NA, rnorm(28), NA), 3, 10))
# mean is 0 and variance is 1apply(x, 1, mean, na.rm = TRUE)
apply(x, 1, var, na.rm = TRUE)
# }