Skip to contents

Identifies and drops outliers within a single-case data frame (scdf).

Usage

outlier(
  data,
  dvar,
  pvar,
  mvar,
  method = c("MAD", "Cook", "SD", "CI"),
  criteria = 3.5
)

Arguments

data

A single-case data frame. See scdf() to learn about this format.

dvar

Character string with the name of the dependent variable. Defaults to the attributes in the scdf file.

pvar

Character string with the name of the phase variable. Defaults to the attributes in the scdf file.

mvar

Character string with the name of the measurement time variable. Defaults to the attributes in the scdf file.

method

Specifies the method for outlier identification. Set method = "MAD" for mean average deiviation, method = "SD" for standard deviations, method = "CI" for confidence intervals, method = "Cook" for Cook's Distance based on the Piecewise Linear Regression Model.

criteria

Specifies the criteria for outlier identification. Based on the method setting.

Value

dataA single-case data frame with substituted outliers.
dropped.nA list with the number of dropped data points for each single-case.
dropped.mtA list with the measurement-times of dropped data points for each single-case (values are based on the mt variable of each single-case data frame).
sd.matrixA list with a matrix for each case with values for the upper and lower boundaries based on the standard deviation.
ci.matrixA list with a matrix for each single-case with values for the upper and lower boundaries based on the confidence interval.
cookA list of Cook's Distances for each measurement of each single-case.
criteriaCriteria used for outlier analysis.
NNumber of single-cases.
case.namesCase identifier.

Details

For method = "SD", criteria = 2 would refer t0 two standard deviations. For method = "MAD", criteria = 3.5 would refer to 3.5 times the mean average deviation. For method = "CI", criteria = 0.99 would refer to a 99 percent confidence interval. For method = "cook", criteria = "4/n" would refer to a Cook's Distance greater than 4/n.

See also

Author

Juergen Wilbert

Examples


## Identify outliers using 1.5 standard deviations as criterion
susanne <- random_scdf(level = 1.0)
res_outlier <- outlier(susanne, method = "SD", criteria = 1.5)
res_outlier
#> Outlier Analysis for Single-Case Data
#> 
#> Case Case1 : Dropped 2 
#> 

## Identify outliers in the original data from Grosche (2011)
## using Cook's Distance greater than 4/n as criterion
res_outlier <- outlier(Grosche2011, method = "Cook", criteria = "4/n")
res_outlier
#> Outlier Analysis for Single-Case Data
#> 
#> Case Eva : Dropped 1 
#> Case Georg : Dropped 2 
#> Case Olaf : Dropped 2 
#>