anomaly (version 2.0.1)

robustscale: robustscale

Description

Transforms the data X by centring and scaling using \(X_{ij}^{'} = \frac{X_{i}-\mu_{i}}{\sigma_{i}}\) where \(\mu_{i}\) and \(\sigma_{i}\) are robust estimates for the mean and standard deviation of each variate (column), \(X_{i}\), of the multivariate time series X. The estimates are calculated using the median and median absolute deviation. This method is the default value for the transform argument used by the capa function, since the capa method assumes that the typical distribution of the data is standard normal.

Usage

robustscale(X)

Arguments

X

A numeric matrix containing the data to be transformed. Each column corresponds to a component and each row to an observation.

Value

A numeric matrix containing the transformed data.

Examples

Run this code
# NOT RUN {
library(anomaly)
# generate some multivariate data
set.seed(0)
X<-simulate(n=1000,p=4,mu=10,locations=c(200,400,600),
            duration=100,proportions=c(0.25,0.5,0.75))
# compare the medians of each variate and transformed variate
head(apply(X,2,median))
head(apply(robustscale(X),2,median))
# compare the variances of each variate and transformed variate
head(apply(X,2,var))
head(apply(robustscale(X),2,var))

# }

Run the code above in your browser using DataCamp Workspace