View source: R/ssMRCD_methods.R
| scale.ssMRCD | R Documentation |
Applies local standardization (scaling and/or centering) of either the original data
from an ssMRCD object or new data provided via the X argument,
using group-wise robust means and variances from the ssMRCD estimation.
## S3 method for class 'ssMRCD'
scale(x, ...)
x |
An object of class |
... |
List of additional arguments including:
|
For each group, the function applies scaling (or just centering) using the robust location and scale (square root of the diagonal of the covariance) estimates obtained during ssMRCD estimation.
A numeric matrix of the same dimension as X, where each observation has
been standardized (or centered) using the corresponding group-wise robust mean and
(if applicable) variance from the ssMRCD model.
If X = NULL, the original data from the ssMRCD object is returned in scaled form,
sorted according to group labels.
ssMRCD
# Simulated example
x1 <- matrix(runif(200), ncol = 2)
x2 <- matrix(rnorm(200), ncol = 2)
x <- list(x1, x2)
W <- matrix(c(0, 1, 1, 0), ncol = 2)
localCovs <- ssMRCD(x, weights = W, lambda = 0.5)
# Scale original data
sc = scale(localCovs)
# Scale new observations
sc = scale(localCovs,
list(X = matrix(rnorm(20), ncol = 2, nrow = 10),
groups = rep(2, 10)))
# Center only
sc = scale(localCovs,
list(X = matrix(rnorm(20), ncol = 2, nrow = 10),
groups = rep(2, 10),
center_only = TRUE))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.