-
Notifications
You must be signed in to change notification settings - Fork 23
/
mvTopCoding.Rd
47 lines (41 loc) · 1.27 KB
/
mvTopCoding.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/mvTopCoding.R
\name{mvTopCoding}
\alias{mvTopCoding}
\title{Detection and winsorization of multivariate outliers}
\usage{
mvTopCoding(x, maha=NULL,center=NULL,cov=NULL, alpha=0.025)
}
\arguments{
\item{x}{object of class matrix with numeric entries}
\item{maha}{squared mahalanobis distance of each observation}
\item{center}{center of data, needed for calcualtion of mahalanobis distance (if not provide)}
\item{cov}{covariance matrix of data, needed for calcualtion of mahalanobis distance (if not provide)}
\item{alpha}{significance level, determining the ellipsoide to which outliers should be placed upon}
}
\value{
the imputed winsorized data
}
\description{
Imputation and detection of outliers
}
\details{
Winsorizes the potential outliers on the ellipsoid defined by MD2 in direction to the center of the data
}
\examples{
set.seed(123)
x <- MASS::mvrnorm(20, mu = c(5,5), Sigma = matrix(c(1,0.9,0.9,1), ncol = 2))
x[1,1] <- 3
x[1,2] <- 6
plot(x)
ximp <- mvTopCoding(x)
# by hand (non-robust)
x[2,2] <- NA
m <- colMeans(x, na.rm = TRUE)
s <- cov(x, use = "complete.obs")
md <- mahalanobis(x, m, s)
ximp <- mvTopCoding(x, center = m, cov = s, maha = md)
}
\author{
Johannes Gussenbauer, Matthias Templ
}