winsorize(x, ...)
## S3 method for class 'default':
winsorize(x, standardized = FALSE,
centerFun = median, scaleFun = mad, const = 2,
return = c("data", "weights"), ...)
## S3 method for class 'matrix':
winsorize(x, standardized = FALSE,
centerFun = median, scaleFun = mad, const = 2,
prob = 0.95, tol = .Machine$double.eps^0.5,
return = c("data", "weights"), ...)
## S3 method for class 'data.frame':
winsorize(x, ...)
median
). Ignored if
standardized
is TRUE
.mad
). Ignored if
standardized
is TRUE
.corHuber
).standardized
is
TRUE
, this specifies the type of return value.
Possible values are "data"
for returning the
cleaned data, or "weights"
for returning data
cleaning weights"data.frame"
method, additional arguments to be
passed down to the "matrix"
method. For the other
methods, additional arguments tostandardize
is TRUE
and return
is
"weights"
, a set of data cleaning weights.
Multiplying each observation of the standardized data by
the corresponding weight yields the cleaned standardized
data.
Otherwise an object of the same type as the original data
x
containing the cleaned data is returned.const
, thus a symmetric distribution is
assumed. In the multivariate case, a normal distribution
is assumed and the data are shrunken towards the boundary
of a tolerance ellipse with coverage probability
prob
. The boundary of this ellipse is thereby
given by all points that have a squared Mahalanobis
distance equal to the quantile of the
$\chi^{2}$ distribution given by
prob
.corHuber
## generate data
set.seed(1234) # for reproducibility
x <- rnorm(10) # standard normal
x[1] <- x[1] * 10 # introduce outlier
## winsorize data
x
winsorize(x)
Run the code above in your browser using DataLab