maximum_normed_residual: Detect outliers using the maximum normed residual method

View source: R/mnr.R

maximum_normed_residualR Documentation

Detect outliers using the maximum normed residual method

Description

This function detects outliers using the maximum normed residual method described in CMH-17-1G. This method identifies a value as an outlier if the absolute difference between the value and the sample mean divided by the sample standard deviation exceeds a critical value.

Usage

maximum_normed_residual(data = NULL, x, alpha = 0.05)

Arguments

data

a data.frame

x

the variable in the data.frame for which to find the MNR or a vector if data=NULL

alpha

the significance level for the test. Defaults to 0.05

Details

data is an optional argument. If data is given, it should be a data.frame (or similar object). When data is specified, the value of x is expected to be a variable within data. If data is not specified, x must be a vector.

The maximum normed residual test is a test for outliers. The test statistic is given in CMH-17-1G. Outliers are identified in the returned object.

The maximum normed residual test statistic is defined as:

MNR = max \frac{\left| x_i - \bar{x} \right|}{s}

When the value of the MNR test statistic exceeds the critical value defined in Section 8.3.3.1 of CMH-17-1G, the corresponding value is identified as an outlier. It is then removed from the sample, and the test statistic is computed again and compared with the critical value corresponding with the new sample. This process is repeated until no values are identified as outliers.

Value

an object of class mnr This object has the following fields:

  • call the expression used to call this function

  • data the original data used to compute the MNR

  • alpha the value of alpha given by the user

  • mnr the computed MNR test statistic

  • crit the critical value given the sample size and the significance level

  • outliers a data.frame containing the index and value of each of the identified outliers

  • n_outliers the number of outliers found

References

“Composite Materials Handbook, Volume 1. Polymer Matrix Composites Guideline for Characterization of Structural Materials,” SAE International, CMH-17-1G, Mar. 2012.

Examples

library(dplyr)

carbon.fabric.2 %>%
  filter(test=="FC" & condition=="ETW2" & batch=="A") %>%
  maximum_normed_residual(strength)

## Call:
## maximum_normed_residual(data = ., x = strength)
##
## MNR =  1.958797  ( critical value = 1.887145 )
##
## Outliers ( alpha = 0.05 ):
##   Index  Value
##       6  44.26

carbon.fabric.2 %>%
  filter(test=="FC" & condition=="ETW2" & batch=="B") %>%
  maximum_normed_residual(strength)

## Call:
## maximum_normed_residual(data = ., x = strength)
##
## MNR =  1.469517  ( critical value = 1.887145 )
##
## No outliers detected ( alpha = 0.05 )


cmstatr documentation built on May 29, 2024, 8:44 a.m.