Learn R Programming

cellWise (version 2.5.3)

MacroPCApredict: MacroPCApredict

Description

Based on a MacroPCA fit of an initial (training) data set X, this function analyzes a new (test) data set Xnew.

Usage

MacroPCApredict(Xnew, InitialMacroPCA, MacroPCApars = NULL)

Value

A list with components:

MacroPCApars

the options used in the call.

DDC

result of DDCpredict which is the first step of MacroPCApredict. See the function DDCpredict.

scaleX

the scales of the columns of X.

k

the number of principal components.

loadings

the columns are the k loading vectors.

eigenvalues

the k eigenvalues.

center

vector with the fitted center.

It

number of iteration steps.

diff

convergence criterion.

Xnew.NAimp

Xnew with all NA's imputed by MacroPCA.

scores

scores of Xnew.NAimp.

OD

orthogonal distances of the rows of Xnew.NAimp.

cutoffOD

cutoff value for the OD.

SD

score distances of the rows of Xnew.NAimp.

cutoffSD

cutoff value for the SD.

highOD

row numbers of cases in Xnew.NAimp whose OD is above cutoffOD.

highSD

row numbers of cases in Xnew.NAimp whose SD is above cutoffSD.

residScale

scale of the residuals.

stdResid

standardized residuals. Note that these are NA for all missing values of Xnew.

indcells

indices of cellwise outliers.

NAimp

various results for the NA-imputed Xnew.

Cellimp

various results for the cell-imputed Xnew.

Fullimp

various result for the fully imputed Xnew.

Arguments

Xnew

The new data (test data), which must be a matrix or a data frame. It must always be provided. Its columns (variables) should correspond to those of InitialMacroPCA$remX.

InitialMacroPCA

The output of the MacroPCA function on the initial (training) dataset. Must be provided.

MacroPCApars

The input options to be used for the prediction. By default the options of InitialMacroPCA are used. For the complete list of options see the function MacroPCA.

Author

Rousseeuw P.J., Van den Bossche W.

References

Hubert, M., Rousseeuw, P.J., Van den Bossche W. (2019). MacroPCA: An all-in-one PCA method allowing for missing values as well as cellwise and rowwise outliers. Technometrics, 61(4), 459-473. (link to open access pdf)

See Also

checkDataSet, cellMap, DDC, DDCpredict, MacroPCA

Examples

Run this code
library(MASS) 
set.seed(12345) 
n <- 50; d <- 10
A <- matrix(0.9, d, d); diag(A) = 1
x <- mvrnorm(n, rep(0,d), A)
x[sample(1:(n * d), 50, FALSE)] <- NA
x[sample(1:(n * d), 50, FALSE)] <- 10
MacroPCA.out <- MacroPCA(x, 2)
xnew <- mvrnorm(25, rep(0,d), A)
xnew[sample(1:(25 * d), 12, FALSE)] <- 10
predict.out <- MacroPCApredict(xnew, MacroPCA.out)
cellMap(predict.out$stdResid)

# For more examples, we refer to the vignette:
if (FALSE) {
vignette("MacroPCA_examples")
}

Run the code above in your browser using DataLab