This function identifies outlier observations in the trajectories, and allows users to replace the observations or remove trajectories entirely.
outlier_detect(traj, id_field = FALSE, method = 1, threshold = 0.95, count = 1, replace_with = 1, verbose=TRUE)
traj | [matrix (numeric)]: longitudinal data. Each row represents an individual trajectory (of observations). The columns show the observations at consecutive time points. |
---|---|
id_field | [numeric or character] Whether the first column
of the |
method | [integer (numeric)] indicating the method for
identifying the outlier. Options are: |
threshold | [numeric] A cut-off value for outliers. If the
|
count | [integer (numeric)] indicating the number of observations
(in a trajectory) that must exceed the |
replace_with | [integer (numeric)] indicating the technique to
use for calculating a replacement for an outlier observation. The remaining
observations on the row or the column in which the outlier observation is
located are used to calculate the replacement.
The replacement options are: |
verbose | to suppress output messages (to the console).
Default: |
A dataframe with outlier observations replaced or removed.
Given a matrix, this function identifies outliers that exceed the threshold and replaces the outliers with an estimate calculated using the other observations either the rows or the columns in which the outlier observation is located. Option is also provided to remove the trajectories (containing the outlier) from the data.
data(traj) trajectry <- data_imputation(traj, id_field=TRUE, method = 1, replace_with = 1, verbose=FALSE) trajectry <- props(trajectry$CompleteData, id_field=TRUE) outp <- outlier_detect(trajectry, id_field = TRUE, method = 1, threshold = 0.95, count = 1, replace_with = 1, verbose=TRUE)#> [1] "1 trajectories were found to contain outlier observations and replaced accordingly!" #> [1] "Summary:" #> [1] "*--Outlier observation(s) was found in trajectory 10 --*"outp <- outlier_detect(trajectry, id_field = TRUE, method = 2, threshold = 15, count = 4, replace_with = 3, verbose=TRUE)#> [1] "No outlier(s) found!"