residuals.ssMRCD: Extracting Residuals from Local Fit

residuals.ssMRCDR Documentation

Extracting Residuals from Local Fit

Description

Extracting Residuals from Local Fit

Usage

## S3 method for class 'ssMRCD'
residuals(object, ...)

Arguments

object

ssMRCD object, see ssMRCD.

...

see details

Details

Other input variables are:

remove_outliers logical (default FALSE). If TRUE, only residuals from not outlying observations are calculated. If FALSE, trimmed residuals are used (see alpha).
X matrix of new data, if data from the ssMRCD object is used.
groups vector of groups for new data, if NULL data from the ssMRCD object is used.
mean logical (default FALSE), specifying if mean of trimmed observations is returned or all residuals.

If X and groups are provided, alpha is set to one and all residuals are used. If remove_outliers is TRUE, alpha is set to 1 automatically.

Value

Returns either all residuals or the mean of the residual norms lower than the alpha- Quantile.

Examples

# create data set
x1 = matrix(runif(200), ncol = 2)
x2 = matrix(rnorm(200), ncol = 2)
x = list(x1, x2)

# create weighting matrix
W = matrix(c(0, 1, 1, 0), ncol = 2)

# calculate ssMRCD
localCovs = ssMRCD(x, weights = W, lambda = 0.5)

# residuals of model
residuals(localCovs, remove_outliers = TRUE, mean = FALSE)

# residuals of new data
residuals(localCovs,
      X = matrix(rnorm(20), ncol = 2, nrow = 10),
      groups = rep(2, 10),
      mean =TRUE)


ssMRCD documentation built on Sept. 11, 2024, 5:14 p.m.