R Under development (unstable) (2024-08-16 r87026 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > ## VT::15.09.2013 - this will render the output independent > ## from the version of the package > suppressPackageStartupMessages(library(rrcovNA)) > > alpha <- 0.55 > > data(phosphor); x <- y <- phosphor[,1:2]; x[10,2] <- NA; x[15,1] <- NA > mcdc <- CovMcd(y) # mcdc - complete > ximp <- impSeq(x); mcds <- CovMcd(ximp) # mcd - sequential imputation + MCD > ximp <- impSeqRob(x, alpha=alpha); mcd <- CovMcd(ximp$x) # mcd - robust sequentioal imputation + MCD > mcdna <- CovNAMcd(x) # mcdna - norm + MCD > as.vector(which(mcdc@wt==0)) [1] 1 6 10 > as.vector(which(mcds@wt==0)) [1] 1 6 > as.vector(which(mcd@wt==0)) [1] 1 4 6 7 16 > as.vector(which(mcdna@wt==0)) integer(0) > ##cbind(mcdc@wt, mcdna@wt, mcd@wt) > > data(heart); x <- y <- heart; x[10,2] <- NA; x[2,1] <- NA > mcdc <- CovMcd(y) > ximp <- impSeq(x); mcds <- CovMcd(ximp) # mcd - sequential imputation + MCD > ximp <- impSeqRob(x, alpha=alpha); mcd <- CovMcd(ximp$x) > mcdna <- CovNAMcd(x) > as.vector(which(mcdc@wt==0)) [1] 3 8 9 10 > as.vector(which(mcds@wt==0)) [1] 3 8 9 10 > as.vector(which(mcd@wt==0)) [1] 3 8 9 10 > as.vector(which(mcdna@wt==0)) integer(0) > ##cbind(mcdc@wt, mcdna@wt, mcd@wt) > > data(starsCYG); x <- y <- starsCYG; x[10,2] <- NA; x[2,1] <- NA; x[33,1] <- NA; x[41,1] <- NA > mcdc <- CovMcd(y) > ximp <- impSeq(x); mcds <- CovMcd(ximp) # mcd - sequential imputation + MCD > ximp <- impSeqRob(x, alpha=alpha); mcd <- CovMcd(ximp$x) > mcdna <- CovNAMcd(x) > as.vector(which(mcdc@wt==0)) [1] 7 9 11 14 20 30 34 > as.vector(which(mcds@wt==0)) [1] 2 7 9 11 14 20 30 34 > as.vector(which(mcd@wt==0)) [1] 7 9 11 14 20 30 34 > as.vector(which(mcdna@wt==0)) integer(0) > ##cbind(mcdc@wt, mcdna@wt, mcd@wt) > > data(stackloss); x <- y <- stack.x; x[10,2] <- NA; x[6,1] <- NA; x[13,3] <- NA > mcdc <- CovMcd(y) > ximp <- impSeq(x); mcds <- CovMcd(ximp) # mcd - sequential imputation + MCD > ximp <- impSeqRob(x, alpha=alpha); mcd <- CovMcd(ximp$x) > mcdna <- CovNAMcd(x) > as.vector(which(mcdc@wt==0)) [1] 1 2 3 15 16 17 18 19 21 > as.vector(which(mcds@wt==0)) [1] 7 8 10 14 17 18 19 20 > as.vector(which(mcd@wt==0)) [1] 1 2 3 15 16 17 18 19 21 > as.vector(which(mcdna@wt==0)) integer(0) > ##cbind(mcdc@wt, mcdna@wt, mcd@wt) > > data(coleman); x <- y <- data.matrix(subset(coleman, select = -Y)); x[5,2] <- NA; x[8,4] <- NA; x[13,3] <- NA > mcdc <- CovMcd(y) > ximp <- impSeq(x); mcds <- CovMcd(ximp) # mcd - sequential imputation + MCD > ximp <- impSeqRob(x, alpha=alpha); mcd <- CovMcd(ximp$x) > mcdna <- CovNAMcd(x) > ##as.vector(which(mcdc@wt==0)) > ##as.vector(which(mcds@wt==0)) > ##as.vector(which(mcd@wt==0)) > ##as.vector(which(mcdna@wt==0)) > ##cbind(mcdc@wt, mcdna@wt, mcd@wt) > > data(salinity); x <- y <- data.matrix(subset(salinity, select = -Y)); x[1,2] <- NA; x[8,3] <- NA; x[13,3] <- NA > mcdc <- CovMcd(y) > ximp <- impSeq(x); mcds <- CovMcd(ximp) # mcd - sequential imputation + MCD > ximp <- impSeqRob(x, alpha=alpha); mcd <- CovMcd(ximp$x) > mcdna <- CovNAMcd(x) > as.vector(which(mcdc@wt==0)) [1] 5 16 23 24 > as.vector(which(mcds@wt==0)) [1] 3 5 11 16 23 24 > as.vector(which(mcd@wt==0)) [1] 3 5 11 16 23 24 > as.vector(which(mcdna@wt==0)) integer(0) > ##cbind(mcdc@wt, mcdna@wt, mcd@wt) > > data(wood); x <- y <- data.matrix(subset(wood, select = -y)); x[1,2] <- NA; x[10,3] <- NA; x[13,4] <- NA > mcdc <- CovMcd(y) > ximp <- impSeq(x); mcds <- CovMcd(ximp) # mcd - sequential imputation + MCD > ximp <- impSeqRob(x, alpha=alpha); mcd <- CovMcd(ximp$x) > mcdna <- CovNAMcd(x) > as.vector(which(mcdc@wt==0)) [1] 4 6 7 8 11 16 19 > as.vector(which(mcds@wt==0)) [1] 1 7 9 11 12 16 17 > as.vector(which(mcd@wt==0)) [1] 4 6 8 19 > as.vector(which(mcdna@wt==0)) integer(0) > ##cbind(mcdc@wt, mcdna@wt, mcd@wt) > > data(hbk); x <- y <- data.matrix(subset(hbk, select = -Y)); x[30,2] <- NA; x[40,3] <- NA; x[17,3] <- NA > mcdc <- CovMcd(y) > ximp <- impSeq(x); mcds <- CovMcd(ximp) # mcd - sequential imputation + MCD > ximp <- impSeqRob(x, alpha=alpha); mcd <- CovMcd(ximp$x) > mcdna <- CovNAMcd(x) > as.vector(which(mcdc@wt==0)) [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 > as.vector(which(mcds@wt==0)) [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 > as.vector(which(mcd@wt==0)) [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 > as.vector(which(mcdna@wt==0)) integer(0) > ##cbind(mcdc@wt, mcdna@wt, mcd@wt) > > proc.time() user system elapsed 0.84 0.14 0.98