Detect the potential outliers from the absolute and relative differences in
BAsummary
object with 4E and ESD method.
Arguments
- object
(
BAsummary
)
input from blandAltman function to generate the Bland-Altman analysis result that contains the absolute and relative differences.- ...
not used.
- method
(
string
)
string specifying which method to use. Default isESD
.- difference
(
string
)
string specifying which difference type to use forESD
method. Default isabs
that means absolute difference, andrel
is relative difference.- alpha
(
numeric
)
type-I-risk. Only used when the method is defined asESD
.- h
(
integer
)
the positive integer indicating the number of suspected outliers. Only used when the method is defined asESD
.
Value
A list contains the statistics results (stat
), outliers' ord id (ord
),
sample id (sid
), matrix with outliers (outmat
) and matrix without outliers (rmmat
).
Note
Bland-Altman analysis is used as the input data regardless of the 4E and ESD method because it's necessary to determine the absolute and relative differences beforehand. For the 4E method, both of the absolute and relative differences are required to be define, and the bias exceeds the 4 fold of the absolute and relative differences. However for the ESD method, only one of them is necessary (the latter is more recommended), and the bias needs to meet the ESD test.
Examples
data("platelet")
# Using `blandAltman` function with default arguments
ba <- blandAltman(x = platelet$Comparative, y = platelet$Candidate)
getOutlier(ba, method = "ESD", difference = "rel")
#> $stat
#> i Mean SD x Obs ESDi Lambda Outlier
#> 1 1 0.06356753 0.1447540 0.6666667 1 4.166372 3.445148 TRUE
#> 2 2 0.05849947 0.1342496 0.5783972 4 3.872621 3.442394 TRUE
#> 3 3 0.05409356 0.1258857 0.5321101 2 3.797226 3.439611 TRUE
#> 4 4 0.05000794 0.1183096 -0.4117647 10 3.903086 3.436800 TRUE
#> 5 5 0.05398874 0.1106738 -0.3132530 14 3.318236 3.433961 FALSE
#> 6 6 0.05718215 0.1056542 -0.2566372 23 2.970250 3.431092 FALSE
#>
#> $ord
#> [1] 1 4 2 10
#>
#> $sid
#> [1] 1 4 2 10
#>
#> $outmat
#> sid x y
#> 1 1 1.5 3.0
#> 2 2 4.0 6.9
#> 3 4 10.2 18.5
#> 4 10 16.4 10.8
#>
#> $rmmat
#> sid x y
#> 1 3 9.2 8.0
#> 2 5 11.2 9.0
#> 3 6 12.4 13.0
#> 4 7 14.8 19.7
#> 5 8 14.8 16.0
#> 6 9 15.9 21.9
#> 7 11 17.6 22.6
#> 8 12 18.1 15.9
#> 9 13 18.1 20.0
#> 10 14 19.2 14.0
#> 11 15 19.6 25.9
#> 12 16 19.9 21.8
#> 13 17 20.4 24.5
#> 14 18 21.2 29.2
#> 15 19 22.0 27.0
#> 16 20 22.2 24.0
#> 17 21 23.4 25.8
#> 18 22 25.2 22.0
#> 19 23 25.5 19.7
#> 20 24 25.6 33.4
#> 21 25 26.3 30.0
#> 22 26 26.4 28.9
#> 23 27 27.5 34.3
#> 24 28 28.2 34.3
#> 25 29 30.3 35.8
#> 26 30 31.4 37.8
#> 27 31 32.9 37.1
#> 28 32 33.9 40.3
#> 29 33 34.3 37.1
#> 30 34 35.3 40.0
#> 31 35 38.4 42.2
#> 32 36 39.2 49.3
#> 33 37 48.2 41.0
#> 34 38 49.0 55.0
#> 35 39 51.3 55.0
#> 36 40 52.2 64.6
#> 37 41 60.2 54.8
#> 38 42 61.5 64.6
#> 39 43 78.0 78.6
#> 40 44 80.6 91.4
#> 41 45 84.4 65.7
#> 42 46 85.3 97.2
#> 43 47 89.0 100.0
#> 44 48 92.6 103.2
#> 45 49 94.9 89.6
#> 46 50 108.6 123.4
#> 47 51 110.4 115.0
#> 48 52 115.6 124.4
#> 49 53 116.9 138.1
#> 50 54 122.7 139.2
#> 51 55 143.6 166.8
#> 52 56 146.1 143.7
#> 53 57 146.2 150.8
#> 54 58 154.5 178.5
#> 55 59 161.7 183.4
#> 56 60 167.7 176.1
#> 57 61 176.6 173.7
#> 58 62 179.7 180.4
#> 59 63 188.9 198.9
#> 60 64 189.0 199.4
#> 61 65 197.9 211.1
#> 62 66 201.7 220.1
#> 63 67 207.7 218.3
#> 64 68 209.2 223.4
#> 65 69 210.5 196.8
#> 66 70 210.9 223.8
#> 67 71 214.1 232.2
#> 68 72 218.6 237.1
#> 69 73 232.9 247.9
#> 70 74 235.0 227.0
#> 71 75 237.8 235.3
#> 72 76 246.1 283.0
#> 73 77 252.6 263.5
#> 74 78 254.9 283.5
#> 75 79 261.4 272.3
#> 76 80 262.4 256.6
#> 77 81 270.1 289.2
#> 78 82 271.3 265.7
#> 79 83 273.5 264.5
#> 80 84 274.2 262.2
#> 81 85 281.1 271.1
#> 82 86 297.0 311.7
#> 83 87 298.7 296.5
#> 84 88 326.7 310.2
#> 85 89 327.1 362.1
#> 86 90 329.6 368.5
#> 87 91 332.8 370.6
#> 88 92 337.4 379.5
#> 89 93 340.1 358.3
#> 90 94 364.8 390.6
#> 91 95 370.1 408.4
#> 92 96 390.6 371.0
#> 93 97 395.7 431.7
#> 94 98 419.3 438.7
#> 95 99 421.3 382.3
#> 96 100 426.3 441.8
#> 97 101 440.4 455.6
#> 98 102 443.4 465.8
#> 99 103 446.2 416.4
#> 100 104 462.7 480.3
#> 101 105 467.7 470.7
#> 102 106 507.4 496.7
#> 103 107 568.3 595.9
#> 104 108 599.6 611.0
#> 105 109 613.8 622.3
#> 106 110 633.5 641.3
#> 107 111 678.6 717.5
#> 108 112 687.6 714.9
#> 109 113 695.1 647.3
#> 110 114 701.0 725.6
#> 111 115 708.3 729.5
#> 112 116 735.6 754.5
#> 113 117 794.8 768.5
#> 114 118 937.0 901.6
#> 115 119 1031.9 1068.0
#> 116 120 1239.3 1279.0
#>
# Using sample id as input
ba2 <- blandAltman(x = platelet$Comparative, y = platelet$Candidate, sid = platelet$Sample)
getOutlier(ba2, method = "ESD", difference = "rel")
#> $stat
#> i Mean SD x Obs ESDi Lambda Outlier
#> 1 1 0.06356753 0.1447540 0.6666667 1 4.166372 3.445148 TRUE
#> 2 2 0.05849947 0.1342496 0.5783972 4 3.872621 3.442394 TRUE
#> 3 3 0.05409356 0.1258857 0.5321101 2 3.797226 3.439611 TRUE
#> 4 4 0.05000794 0.1183096 -0.4117647 10 3.903086 3.436800 TRUE
#> 5 5 0.05398874 0.1106738 -0.3132530 14 3.318236 3.433961 FALSE
#> 6 6 0.05718215 0.1056542 -0.2566372 23 2.970250 3.431092 FALSE
#>
#> $ord
#> [1] 1 4 2 10
#>
#> $sid
#> [1] "ID1" "ID4" "ID2" "ID10"
#>
#> $outmat
#> sid x y
#> 1 ID1 1.5 3
#> 2 ID2 4 6.9
#> 3 ID4 10.2 18.5
#> 4 ID10 16.4 10.8
#>
#> $rmmat
#> sid x y
#> 1 ID3 9.2 8
#> 2 ID5 11.2 9
#> 3 ID6 12.4 13
#> 4 ID7 14.8 19.7
#> 5 ID8 14.8 16
#> 6 ID9 15.9 21.9
#> 7 ID11 17.6 22.6
#> 8 ID12 18.1 15.9
#> 9 ID13 18.1 20
#> 10 ID14 19.2 14
#> 11 ID15 19.6 25.9
#> 12 ID16 19.9 21.8
#> 13 ID17 20.4 24.5
#> 14 ID18 21.2 29.2
#> 15 ID19 22 27
#> 16 ID20 22.2 24
#> 17 ID21 23.4 25.8
#> 18 ID22 25.2 22
#> 19 ID23 25.5 19.7
#> 20 ID24 25.6 33.4
#> 21 ID25 26.3 30
#> 22 ID26 26.4 28.9
#> 23 ID27 27.5 34.3
#> 24 ID28 28.2 34.3
#> 25 ID29 30.3 35.8
#> 26 ID30 31.4 37.8
#> 27 ID31 32.9 37.1
#> 28 ID32 33.9 40.3
#> 29 ID33 34.3 37.1
#> 30 ID34 35.3 40
#> 31 ID35 38.4 42.2
#> 32 ID36 39.2 49.3
#> 33 ID37 48.2 41
#> 34 ID38 49 55
#> 35 ID39 51.3 55
#> 36 ID40 52.2 64.6
#> 37 ID41 60.2 54.8
#> 38 ID42 61.5 64.6
#> 39 ID43 78 78.6
#> 40 ID44 80.6 91.4
#> 41 ID45 84.4 65.7
#> 42 ID46 85.3 97.2
#> 43 ID47 89 100
#> 44 ID48 92.6 103.2
#> 45 ID49 94.9 89.6
#> 46 ID50 108.6 123.4
#> 47 ID51 110.4 115
#> 48 ID52 115.6 124.4
#> 49 ID53 116.9 138.1
#> 50 ID54 122.7 139.2
#> 51 ID55 143.6 166.8
#> 52 ID56 146.1 143.7
#> 53 ID57 146.2 150.8
#> 54 ID58 154.5 178.5
#> 55 ID59 161.7 183.4
#> 56 ID60 167.7 176.1
#> 57 ID61 176.6 173.7
#> 58 ID62 179.7 180.4
#> 59 ID63 188.9 198.9
#> 60 ID64 189 199.4
#> 61 ID65 197.9 211.1
#> 62 ID66 201.7 220.1
#> 63 ID67 207.7 218.3
#> 64 ID68 209.2 223.4
#> 65 ID69 210.5 196.8
#> 66 ID70 210.9 223.8
#> 67 ID71 214.1 232.2
#> 68 ID72 218.6 237.1
#> 69 ID73 232.9 247.9
#> 70 ID74 235 227
#> 71 ID75 237.8 235.3
#> 72 ID76 246.1 283
#> 73 ID77 252.6 263.5
#> 74 ID78 254.9 283.5
#> 75 ID79 261.4 272.3
#> 76 ID80 262.4 256.6
#> 77 ID81 270.1 289.2
#> 78 ID82 271.3 265.7
#> 79 ID83 273.5 264.5
#> 80 ID84 274.2 262.2
#> 81 ID85 281.1 271.1
#> 82 ID86 297 311.7
#> 83 ID87 298.7 296.5
#> 84 ID88 326.7 310.2
#> 85 ID89 327.1 362.1
#> 86 ID90 329.6 368.5
#> 87 ID91 332.8 370.6
#> 88 ID92 337.4 379.5
#> 89 ID93 340.1 358.3
#> 90 ID94 364.8 390.6
#> 91 ID95 370.1 408.4
#> 92 ID96 390.6 371
#> 93 ID97 395.7 431.7
#> 94 ID98 419.3 438.7
#> 95 ID99 421.3 382.3
#> 96 ID100 426.3 441.8
#> 97 ID101 440.4 455.6
#> 98 ID102 443.4 465.8
#> 99 ID103 446.2 416.4
#> 100 ID104 462.7 480.3
#> 101 ID105 467.7 470.7
#> 102 ID106 507.4 496.7
#> 103 ID107 568.3 595.9
#> 104 ID108 599.6 611
#> 105 ID109 613.8 622.3
#> 106 ID110 633.5 641.3
#> 107 ID111 678.6 717.5
#> 108 ID112 687.6 714.9
#> 109 ID113 695.1 647.3
#> 110 ID114 701 725.6
#> 111 ID115 708.3 729.5
#> 112 ID116 735.6 754.5
#> 113 ID117 794.8 768.5
#> 114 ID118 937 901.6
#> 115 ID119 1031.9 1068
#> 116 ID120 1239.3 1279
#>
# Using `blandAltman` function when the `tyep2` is 2 with `X vs. (Y-X)/X` difference
ba3 <- blandAltman(x = platelet$Comparative, y = platelet$Candidate, type2 = 4)
getOutlier(ba3, method = "ESD", difference = "rel")
#> $stat
#> i Mean SD x Obs ESDi Lambda Outlier
#> 1 1 0.07824269 0.1730707 1.0000000 1 5.325900 3.445148 TRUE
#> 2 2 0.07049683 0.1514810 0.8137255 4 4.906415 3.442394 TRUE
#> 3 3 0.06419828 0.1355778 0.7250000 2 4.873967 3.439611 TRUE
#> 4 4 0.05855040 0.1214221 -0.3414634 10 3.294407 3.436800 FALSE
#> 5 5 0.06199880 0.1160523 -0.2708333 14 2.867950 3.433961 FALSE
#> 6 6 0.06489299 0.1122769 0.3773585 18 2.782991 3.431092 FALSE
#>
#> $ord
#> [1] 1 4 2
#>
#> $sid
#> [1] 1 4 2
#>
#> $outmat
#> sid x y
#> 1 1 1.5 3.0
#> 2 2 4.0 6.9
#> 3 4 10.2 18.5
#>
#> $rmmat
#> sid x y
#> 1 3 9.2 8.0
#> 2 5 11.2 9.0
#> 3 6 12.4 13.0
#> 4 7 14.8 19.7
#> 5 8 14.8 16.0
#> 6 9 15.9 21.9
#> 7 10 16.4 10.8
#> 8 11 17.6 22.6
#> 9 12 18.1 15.9
#> 10 13 18.1 20.0
#> 11 14 19.2 14.0
#> 12 15 19.6 25.9
#> 13 16 19.9 21.8
#> 14 17 20.4 24.5
#> 15 18 21.2 29.2
#> 16 19 22.0 27.0
#> 17 20 22.2 24.0
#> 18 21 23.4 25.8
#> 19 22 25.2 22.0
#> 20 23 25.5 19.7
#> 21 24 25.6 33.4
#> 22 25 26.3 30.0
#> 23 26 26.4 28.9
#> 24 27 27.5 34.3
#> 25 28 28.2 34.3
#> 26 29 30.3 35.8
#> 27 30 31.4 37.8
#> 28 31 32.9 37.1
#> 29 32 33.9 40.3
#> 30 33 34.3 37.1
#> 31 34 35.3 40.0
#> 32 35 38.4 42.2
#> 33 36 39.2 49.3
#> 34 37 48.2 41.0
#> 35 38 49.0 55.0
#> 36 39 51.3 55.0
#> 37 40 52.2 64.6
#> 38 41 60.2 54.8
#> 39 42 61.5 64.6
#> 40 43 78.0 78.6
#> 41 44 80.6 91.4
#> 42 45 84.4 65.7
#> 43 46 85.3 97.2
#> 44 47 89.0 100.0
#> 45 48 92.6 103.2
#> 46 49 94.9 89.6
#> 47 50 108.6 123.4
#> 48 51 110.4 115.0
#> 49 52 115.6 124.4
#> 50 53 116.9 138.1
#> 51 54 122.7 139.2
#> 52 55 143.6 166.8
#> 53 56 146.1 143.7
#> 54 57 146.2 150.8
#> 55 58 154.5 178.5
#> 56 59 161.7 183.4
#> 57 60 167.7 176.1
#> 58 61 176.6 173.7
#> 59 62 179.7 180.4
#> 60 63 188.9 198.9
#> 61 64 189.0 199.4
#> 62 65 197.9 211.1
#> 63 66 201.7 220.1
#> 64 67 207.7 218.3
#> 65 68 209.2 223.4
#> 66 69 210.5 196.8
#> 67 70 210.9 223.8
#> 68 71 214.1 232.2
#> 69 72 218.6 237.1
#> 70 73 232.9 247.9
#> 71 74 235.0 227.0
#> 72 75 237.8 235.3
#> 73 76 246.1 283.0
#> 74 77 252.6 263.5
#> 75 78 254.9 283.5
#> 76 79 261.4 272.3
#> 77 80 262.4 256.6
#> 78 81 270.1 289.2
#> 79 82 271.3 265.7
#> 80 83 273.5 264.5
#> 81 84 274.2 262.2
#> 82 85 281.1 271.1
#> 83 86 297.0 311.7
#> 84 87 298.7 296.5
#> 85 88 326.7 310.2
#> 86 89 327.1 362.1
#> 87 90 329.6 368.5
#> 88 91 332.8 370.6
#> 89 92 337.4 379.5
#> 90 93 340.1 358.3
#> 91 94 364.8 390.6
#> 92 95 370.1 408.4
#> 93 96 390.6 371.0
#> 94 97 395.7 431.7
#> 95 98 419.3 438.7
#> 96 99 421.3 382.3
#> 97 100 426.3 441.8
#> 98 101 440.4 455.6
#> 99 102 443.4 465.8
#> 100 103 446.2 416.4
#> 101 104 462.7 480.3
#> 102 105 467.7 470.7
#> 103 106 507.4 496.7
#> 104 107 568.3 595.9
#> 105 108 599.6 611.0
#> 106 109 613.8 622.3
#> 107 110 633.5 641.3
#> 108 111 678.6 717.5
#> 109 112 687.6 714.9
#> 110 113 695.1 647.3
#> 111 114 701.0 725.6
#> 112 115 708.3 729.5
#> 113 116 735.6 754.5
#> 114 117 794.8 768.5
#> 115 118 937.0 901.6
#> 116 119 1031.9 1068.0
#> 117 120 1239.3 1279.0
#>
# Using "4E" as the method input
ba4 <- blandAltman(x = platelet$Comparative, y = platelet$Candidate)
getOutlier(ba4, method = "4E")
#> No outlier is detected.