Augment accepts an mnr object (returned from the function maximum_normed_residual()) and a dataset and adds the column .outlier to the dataset. The column .outlier is a logical vector indicating whether each observation is an outlier.

When passing data into augment using the data argument, the data must be exactly the data that was passed to maximum_normed_residual.

# S3 method for mnr
augment(x, data = x$data, ...)

Arguments

x

an mnr object created by maximum_normed_residual()

data

a data.frame or tibble::tibble() containing the original data that was passed to maximum_normed_residual

...

Additional arguments. Not used. Included only to match generic signature.

Value

When data is supplied, augment returns data, but with one column appended. When data is not supplied, augment

returns a new tibble::tibble() with the column values containing the original values used by maximum_normed_residaul plus one additional column. The additional column is:

  • .outler a logical value indicating whether the observation is an outlier

Examples

data <- data.frame(strength = c(80, 98, 96, 97, 98, 120))
m <- maximum_normed_residual(data, strength)

# augment can be called with the original data
augment(m, data)
#>   strength .outlier
#> 1       80    FALSE
#> 2       98    FALSE
#> 3       96    FALSE
#> 4       97    FALSE
#> 5       98    FALSE
#> 6      120    FALSE

##   strength .outlier
## 1       80    FALSE
## 2       98    FALSE
## 3       96    FALSE
## 4       97    FALSE
## 5       98    FALSE
## 6      120    FALSE

# or augment can be called without the orignal data and it will be
# reconstructed
augment(m)
#> # A tibble: 6 × 2
#>   values .outlier
#>    <dbl> <lgl>   
#> 1     80 FALSE   
#> 2     98 FALSE   
#> 3     96 FALSE   
#> 4     97 FALSE   
#> 5     98 FALSE   
#> 6    120 FALSE   

## # A tibble: 6 x 2
##   values .outlier
##    <dbl> <lgl>
## 1     80 FALSE
## 2     98 FALSE
## 3     96 FALSE
## 4     97 FALSE
## 5     98 FALSE
## 6    120 FALSE