Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ BugReports: https://github.com/pridiltal/stray/issues
License: GPL-2
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.1.0
RoxygenNote: 7.1.1
12 changes: 7 additions & 5 deletions R/find_HDoutliers.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#' @param k Number of neighbours considered.
#' @param knnsearchtype A character vector indicating the search type for k- nearest-neighbors.
#' @param normalize Method to normalize the columns of the data. This prevents variables with large variances
#' having disproportional influence on Euclidean distances. Two options are available "standardize" or "unitize".
#' Default is set to "unitize"
#' having disproportional influence on Euclidean distances. Three options are available: "standardize", "unitize" or "none".
#' Default is set to "unitize". If "none" is passed, no normalization will be used (not recommended.)
#' @param p Proportion of possible candidates for outliers. This defines the starting point for the
#' bottom up searching algorithm. Default is set to 0.5.
#' @param tn Sample size to calculate an emperical threshold. Default is set to 50.
Expand Down Expand Up @@ -38,7 +38,8 @@
#'
find_HDoutliers <- function(data, alpha = 0.01, k = 10,
knnsearchtype = "brute",
normalize = "unitize", p = 0.5, tn =50) {
normalize = c("unitize", "standardize", "none"), p = 0.5, tn =50) {
normalize <- match.arg(normalize, choices = c("unitize", "standardize", "none"))
data <- as.matrix(data)
r <- nrow(data)
data[is.infinite(data)] <- NA
Expand All @@ -62,8 +63,9 @@ find_HDoutliers <- function(data, alpha = 0.01, k = 10,
standardize <- function(z) {
(z - stats::median(z)) / stats::IQR(z)
}

data <- apply(as.matrix(naomit_data), 2, normalize)
if (normalize != "none") {
data <- apply(as.matrix(naomit_data), 2, normalize)
}
out <- use_KNN(data, alpha, k = k, knnsearchtype = knnsearchtype, p = p, tn=tn)
outliers <- tag[out$outliers]
type <- as.factor(ifelse(1:r %in% outliers,
Expand Down
6 changes: 3 additions & 3 deletions man/find_HDoutliers.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.