outlier: Outlier detection

Description Usage Arguments Value Author(s) References Examples

View source: R/outlier.R

Description

Identifies outliers based on the nearest neighbour criterion. It starts by computing a matrix of distances (correlation, r, used as distance, dr=(1-r)/2). Variables with nearest neighbour distance larger than parameter thresh are considered outliers.

Usage

1
2
3
4
5
6
7
8
9
outlier(veg, thresh, y,...)
outly(veg, thresh = 0.2, y = 0.5)

## Default S3 method:
outlier(veg, thresh, y,...)
## S3 method for class 'outlier'
plot(x,...)
## S3 method for class 'outlier'
print(x,...)

Arguments

veg

This is a vegetation data frame, releves are rows, species columns

thresh

Threshold nearest neighbour distance for outliers

y

Transformation of species scores: x'= x exp(y)

x

An object of class "outlier"

...

Parameter out.seq, the plotting interval

Value

An object of class "oulier" with at least the following items:

threshold

Threshold nearest neighbour distance for considering outliers

y

Transformation of species scores: x'= x exp(y)

rel.names

All row names

neigh.names

Names of the corresponding nearest neighbours

neigh.dist

Distance to the nearest neighbour

olddim

Dimensions of data frame veg

newdim

Dimensions of data frame with outliers erased

new.data

Vegetation data frame without outliers

pco.points

The pco ordination scores use for plotting

Author(s)

Otto Wildi

References

Wildi, O. 2017. Data Analysis in Vegetation Ecology. 3rd ed. CABI, Oxfordshire, Boston.

Examples

1
2
3
4
o.outlier<- outlier(nveg,thresh=0.2,y=0.5)
o.outlier                                    # a list of all variables
plot(o.outlier)                              # nearest neighbour histogram and
                                             # pco ordination 

Example output

Loading required package: labdsv
Loading required package: mgcv
Loading required package: nlme
This is mgcv 1.8-20. For overview type 'help("mgcv-package")'.
Loading required package: MASS
Loading required package: cluster

Attaching package: 'labdsv'

The following object is masked from 'package:stats':

    density

Loading required package: vegan
Loading required package: permute
Loading required package: lattice
This is vegan 2.4-4
Call:
outlier.default(veg = nveg, thresh = 0.2, y = 0.5)

Threshold value:                      0.2 
Original number of releves, species:  11 21 
Remaining number of releves, species: 10 21 
$threshold
[1] 0.2

$y
[1] 0.5

$rel.names
 [1] "2"  "4"  "6"  "9"  "10" "18" "25" "27" "39" "49" "50"

$neigh.names
 [1] "6"  "10" "2"  "39" "4"  "9"  "49" "4"  "9"  "2"  "9" 

$neigh.dist
         2          4          6          9         10         18         25 
0.11050856 0.14115809 0.11050856 0.07310725 0.14115809 0.11175884 0.15612706 
        27         39         49         50 
0.17173665 0.07310725 0.12625106 0.23387803 

$olddim
[1] 11 21

$newdim
[1] 10 21

$new.data
   Fagus.silvatica Quercus.petraea Acer.pseudoplatanus Fraxinus.excelsior
2                4               2                   0                  0
4                1               0                   2                  4
6                5               3                   0                  0
9                5               2                   2                  1
10               3               0                   3                  4
18               6               1                   1                  1
25               5               4                   0                  0
27               2               1                   5                  3
39               6               1                   1                  0
49               3               5                   0                  0
   Lonicera.xylosteum Sambucus.racemosa Sambucus.nigra Vaccinium.myrtillus
2                   1                 3              0                   3
4                   2                 0              1                   0
6                   0                 2              0                   2
9                   0                 0              0                   0
10                  1                 0              3                   0
18                  0                 0              1                   0
25                  1                 0              0                   0
27                  2                 0              2                   0
39                  1                 0              0                   0
49                  0                 1              0                   1
   Carex.silvatica Oxalis.acetosella Viola.silvestris Luzula.nemorosa
2                1                 1                1               3
4                1                 2                1               0
6                2                 1                1               1
9                1                 2                2               0
10               0                 3                0               0
18               3                 2                0               0
25               0                 1                0               2
27               3                 0                1               0
39               1                 4                1               0
49               1                 0                1               3
   Veronica.officinalis Galium.odoratum Lamium.galeobdolon Primula.elatior
2                     2               1                  1               0
4                     0               1                  3               1
6                     2               0                  1               0
9                     0               2                  1               0
10                    0               1                  2               3
18                    0               3                  0               0
25                    1               1                  0               0
27                    0               2                  3               3
39                    0               1                  1               0
49                    1               1                  0               0
   Allium.ursinum Arum.maculatum Ranunculus.ficaria Eurhynchium.striatum
2               0              0                  0                    2
4               5              2                  2                    1
6               0              0                  0                    0
9               0              0                  0                    2
10              3              0                  3                    0
18              0              0                  0                    1
25              0              0                  0                    1
27              1              1                  5                    1
39              0              0                  0                    1
49              0              0                  0                    1
   Polytrichum.formosum
2                     1
4                     0
6                     2
9                     0
10                    0
18                    0
25                    1
27                    0
39                    0
49                    4

$pco.points
           [,1]        [,2]
2   0.395765653 -0.05447323
4  -0.458798003 -0.05379030
6   0.342524909  0.02710086
9  -0.009389125  0.03060530
10 -0.377361453 -0.08580198
18 -0.020083220 -0.04031167
25  0.236752837 -0.12199089
27 -0.370532471  0.08710922
39  0.014124262 -0.10817729
49  0.403944819  0.12045772
50 -0.156948207  0.19927226

$call
outlier.default(veg = nveg, thresh = 0.2, y = 0.5)

attr(,"class")
[1] "outlier"

dave documentation built on Nov. 17, 2017, 7:45 a.m.