| Title: | Reference Intervals |
|---|---|
| Description: | This is a collection of tools to allow the medical professional to calculate appropriate reference ranges (intervals) with confidence intervals around the limits for diagnostic purposes. |
| Authors: | Daniel Finnegan |
| Maintainer: | Daniel Finnegan <[email protected]> |
| License: | GPL-3 |
| Version: | 1.3.1 |
| Built: | 2026-06-03 09:17:15 UTC |
| Source: | https://github.com/cran/referenceIntervals |
This package also calculates the confidence intervals around the calculated reference intervals in order to provide a metric for how precise the calculations are. This package also contains four outlier detection functions.
| Package: | referenceIntervals |
| Type: | Package |
| Version: | 1.3.1 |
| Date: | 2024-03-30 |
| License: | GPL-3 |
Daniel Finnegan
Maintainer: Daniel Finnegan <[email protected]>
Clinical and Laboratory Standards Institute. Defining, Establishing, and Verifying Reference Intervals in the Clinical Laboratory; Approved Guideline - Third Edition. C28-A3c. 28(30).
Friedman JH. A recursive partitioning decision rule for nonparametric classification. IEEE Transactions on Computers. 1977. April: 404-408.
Friedrichs KR, Harr KE, Freeman KP, et al. ASVCP reference interval guidelines: determination of de novo reference intervals in veterinary species and other related topics. Vet Clin Pathol. 2012;441-453.
H.E. Solberg Department of Clinical Chemistry. Approved recommendation (1987) on the theory of reference values. Part 5. Statistical treatment of collected reference values. Determination of reference limits. Clinica Chimica Acta. 1987:S13-S32.
Horn PS, Pesce AJ. Reference intervals: an update. Clinica Chimica Acta. 2003. 334:5-23.
Horn PS, Pesce AJ, Copeland BE. A robust approach to reference interval estimation and evaluation. Clinical Chemistry. 1998. 44(3):622-631.
Horn PS, Pesce AJ, Copeland BE. Reference interval computation using robust vs parametric and nonparametric analyses. Clinical Chemistry. 1999. 45(12):2284-2285.
Linnet K. Nonparametric estimation of reference intervals by simple and bootstrap-based procedures. Clinical Chemistry. 2000. 46(6):867-869.
Verma SP, Quiroz-Ruiz A. Critical values for six Dixon tests for outliers in normal samples up to sizes 100, and applications in science and engineering. Revista Mexicana de Ciencias Geologicas. 2006. 23(2):133-161.
Verma SP, Quiroz-Ruiz A, Diaz-Gonzalez L. Critical values for 33 discordancy test variants for outliers in normal samples up to sizes 1000, and applications in quality control in Earth Sciences. Revista Mexicana de Ciencias Geologicas. 2008. 25(1):82-96.
Virtanen A, Kairisto V, Uusipaikka E. Regression-based reference limits: determination of sufficient sample size. Clinical Chemistry. 1998. 44(11):2353-2358.
refLimit(set50, out.rm = TRUE, out.method = "cook") refLimit(set200, out.method = "horn", RI = "n", refConf = 0.90, limitConf = 0.80) horn.outliers(set120) dixon.outliers(set20) refLimit(set50, out.method = "vanderLoo", out.rm = TRUE, RI = "r", bootStat = "perc") frame = data.frame(one = rnorm(30, m = 5, sd = 2), two = rnorm(30, m = 7, sd = 1), three = rnorm(30, m = 2, sd = 0.5)) result = refLimit(frame) plot(result)refLimit(set50, out.rm = TRUE, out.method = "cook") refLimit(set200, out.method = "horn", RI = "n", refConf = 0.90, limitConf = 0.80) horn.outliers(set120) dixon.outliers(set20) refLimit(set50, out.method = "vanderLoo", out.rm = TRUE, RI = "r", bootStat = "perc") frame = data.frame(one = rnorm(30, m = 5, sd = 2), two = rnorm(30, m = 7, sd = 1), three = rnorm(30, m = 2, sd = 0.5)) result = refLimit(frame) plot(result)
A linear regression model is calculated for the data (which is the mean for one-dimensional data. From that, using the Cook Distances of each data point, outliers are determined and returned.
cook.outliers(data)cook.outliers(data)
data |
A vector of data points. |
Returns a list containing a vector of outliers and a vector of the cleaned data (subset).
outliers |
A vector of outliers from the data set |
subset |
A vector containing the remaining data, cleaned of outliers |
Daniel Finnegan
cook.outliers(set50) plot(cook.outliers(set50)$subset)cook.outliers(set50) plot(cook.outliers(set50)$subset)
This determines outliers of the dataset by calculating Dixon's Q statistic and comparing it to a standardized table of statistics. This method can only determine outliers for datasets of size 3 <= n <= 30. This function requires the outliers package.
dixon.outliers(data)dixon.outliers(data)
data |
A vector of data points. |
Returns a list containing a vector of outliers and a vector of the cleaned data (subset).
outliers |
A vector of outliers from the data set |
subset |
A vector containing the remaining data, cleaned of outliers |
Daniel Finnegan
Statistical treatment for rejection of deviant values: critical values of Dixon's "Q" parameter and related subrange ratios at the 95 (2), pp 139-146 DOI: 10.1021/ac00002a010. Publication Date: January 1991
One-sided and Two-sided Critical Values for Dixon's Outlier Test for Sample Sizes up to n = 30. Economic Quality Control, Vol 23(2008), No. 1, 5-13.
dixon.outliers(set20) summary(dixon.outliers(set20)$subset)dixon.outliers(set20) summary(dixon.outliers(set20)$subset)
This function determines outliers in a Box-Cox transformed dataset using Horn's method of outlier detection using Tukey's interquartile fences. If a data point lies outside 1.5 * IQR from the 1st or 3rd quartile point, it is an outlier.
horn.outliers(data)horn.outliers(data)
data |
A vector of data points. |
Returns a list containing a vector of outliers and a vector of the cleaned data (subset).
outliers |
A vector of outliers from the data set |
subset |
A vector containing the remaining data, cleaned of outliers |
Daniel Finnegan
ASVCP reference interval guidelines: determination of de novo reference intervals in veterinary species and other related topics. Vet Clin Pathol 41/4 (2012) 441-453, 2012 American Society for Veterinary Clinical Pathology
Horn, P. S., Feng, L., Li, Y., & Pesce, A. J. (2001). Effect of outliers and nonhealthy individuals on reference interval estimation. Clinical Chemistry, 47(12), 2137-2145.
Horn, P.S., Pesce, A.J. (2003). Reference Intervals: an update. Clin Chim Acta. 334(1-2):5-23. DOI: doi: 10.1016/s0009-8981(03)00133-5.
horn.outliers(set200)horn.outliers(set200)
This is a table that dictate the ranks for the confidence intervals around the calculated reference interval. This method is available when 120 <= n <= 1000.
nonparRanksnonparRanks
A data frame with 882 observations on the following 3 variables.
SampleSizea numeric vector
Lowera numeric vector
Uppera numeric vector
Defining, Establishing, and Verifying Reference Intervals in the Clinical Laboratory; Approved Guideline - 3rd Edition (C28-A3)
data(nonparRanks)data(nonparRanks)
This function uses the appropriate percentiles as determined by refConf to return the non-parametric reference interval. This is written as a boot function to use within the function refLimit.
nonparRI(data, indices = 1:length(data), refConf = 0.95)nonparRI(data, indices = 1:length(data), refConf = 0.95)
data |
data is a vector of sample values. |
indices |
The indices of data to be used in the calculations. The default is to use the whole set. |
refConf |
refConf is a measure of the range covered by the calculation. Most often, as is the default, 95 |
Returns a vector of two values, the lower and upper limits of the reference interval.
Daniel Finnegan
Defining, Establishing, and Verifying Reference Intervals in the Clinical Laboratory; Approved Guideline - 3rd Edition (C28-A3)
nonparRI(set50) nonparRI(set50, refConf = 0.9)nonparRI(set50) nonparRI(set50, refConf = 0.9)
Plots the reference interval and confidence intervals around the limits of the reference interval.
## S3 method for class 'interval' plot(x, main, ...)## S3 method for class 'interval' plot(x, main, ...)
x |
Object x is of type "interval". |
main |
Title of plot. |
... |
Arguments to be passed to methods, such as graphical parameters (see 'par'). |
No return value.
Daniel Finnegan
result = refLimit(set200) plot(result)result = refLimit(set200) plot(result)
This function allows for the pretty-printing of a large list object created by calling the refLimit function.
## S3 method for class 'interval' print(x, digits = 4L, quote = TRUE, prefix = "", ...)## S3 method for class 'interval' print(x, digits = 4L, quote = TRUE, prefix = "", ...)
x |
x is an object of type "interval" |
digits |
minimal number of _significant_ digits. See 'print.default'. |
quote |
logical, indicating whether or not strings should be printed with surrounding quotes. |
prefix |
Option to specify a formatting prefix. |
... |
further arguments passed to or from other methods. |
No return value.
Daniel Finnegan
result = refLimit(set120) resultresult = refLimit(set120) result
This function allows for the pretty-printing of a large list object created by calling the refLimit function.
## S3 method for class 'interval.sub' print(x, digits = 4L, quote = TRUE, prefix = "", ...)## S3 method for class 'interval.sub' print(x, digits = 4L, quote = TRUE, prefix = "", ...)
x |
x is an object of type "interval" |
digits |
minimal number of _significant_ digits. See 'print.default'. |
quote |
logical, indicating whether or not strings should be printed with surrounding quotes. |
prefix |
Option to specify a formatting prefix. |
... |
further arguments passed to or from other methods. |
No return value.
Daniel Finnegan
This function calculates a reference interval from a dataset using parametric, non-parametric, or robust methods.
refLimit(data, out.method = "horn", out.rm = FALSE, RI = "p", CI = "p", refConf = 0.95, limitConf = 0.9, bootStat = "basic")refLimit(data, out.method = "horn", out.rm = FALSE, RI = "p", CI = "p", refConf = 0.95, limitConf = 0.9, bootStat = "basic")
data |
A vector of data points. |
out.method |
The outlier detection method. Valid options include "horn", "cook", "dixon", and "vanderLoo". |
out.rm |
Remove outliers. If value is TRUE, outliers will be automatically removed prior to calculations. If FALSE (default), outliers will be detected but not removed. |
RI |
Method for reference interval calculations. Valid options include "p" (default) for parametric, "n" for non-parametric, and "r" for robust method. |
CI |
Method for confidence interval calculations. Valid options include "p" for parametric (default), "n" for non-parametric, and "boot" for bootstrapping method. The minimum samplesize for non-parametric confidence interval calculations is 120. With smaller samples, bootstrapping methods are used. |
refConf |
Desired coverage for the calculated reference interval. The default is a 95 interval. |
limitConf |
Desired confidence interval level. The default is a 90 reference interval limits. |
bootStat |
Method for calculating confidence intervals from package boot. Valid arguments include "basic" (basic bootstrap method), "perc" (bootstrap percentile method), "norm" (normal approximation method), "stud" (studentized bootstrap method), and "bca" (adjusted bootstrap percentile method). |
A confidence interval around each limit of the reference interval is calculated as a metric for determining the validity of the result. Outliers can be detected in one of four different methods and automatically eliminated.
To determine the most appropriate calculation for confidence intervals using the bootstrapping method, please consult chapter 5 of Davison and Hinkley's "Bootstrap Methods and their Applications."
Returns a list of necessary information.
size |
Size of dataset |
dname |
Name of dataset |
out.method |
Outlier detection method |
out.rm |
Boolean indicating whether outliers are automatically removed |
outliers |
Vector of detected outliers |
methodRI |
Method for reference interval calculations (p, n, or r) |
methodCI |
Method for confidence interval calculations (p, n, boot) |
norm |
Results of running Shapiro-Wilk and Kolmorgorov-Smirnov normacy tests |
refConf |
Desired coverage of reference interval |
limitConf |
Desired confidence interval level |
Ref_Int |
List containing the reference interval and confidence interval values |
Daniel Finnegan
ASVCP reference interval guidelines: determination of de novo reference intervals in veterinary species and other related topics. Vet Clin Pathol 41/4 (2012) 441-453, 2012. American Society for Veterinary Clinical Pathology
Davison, A.C. and Hinkley, D.V. (1997) Bootstrap Methods and Their Application, Chapter 5. Cambridge University Press.
refLimit(set20, out.method = "dixon") refLimit(set200, out.method = "cook", out.rm = TRUE, RI = "n", refConf = 0.9) refLimit(set50, out.method = "vanderLoo", out.rm = TRUE, RI = "r", bootStat = "perc")refLimit(set20, out.method = "dixon") refLimit(set200, out.method = "cook", out.rm = TRUE, RI = "n", refConf = 0.9) refLimit(set50, out.method = "vanderLoo", out.rm = TRUE, RI = "r", bootStat = "perc")
The robust method is an iterative method that determines the most appropriate weighted mean of the data and then calculates the desired reference interval.
robust(data, indices = c(1:length(data)), refConf = 0.95)robust(data, indices = c(1:length(data)), refConf = 0.95)
data |
Vector of data. |
indices |
Indices of data to use for calculations. |
refConf |
Desired coverage of the reference interval. Default is 95 interval. |
Returns a vector containing the lower and upper limits of the reference interval.
Daniel Finnegan
Defining, Establishing, and Verifying Reference Intervals in the Clinical Laboratory; Approved Guideline - 3rd Edition (C28-A3)
robust(set50) robust(horn.outliers(set20)$subset)robust(set50) robust(horn.outliers(set20)$subset)
Small dataset containing 120 samples. The mean is centered on 27 with a standard deviation of 7.
set120set120
The format is: num [1:120] 38.1 12.6 31.3 35.5 22.6 ...
rnorm(120, m = 27, sd = 7)
data(set120)data(set120)
Small dataset containing 20 samples. The mean is centered on 42 with a standard deviation of 5.
set20set20
The format is: num [1:20] 35 32.9 43.6 44.6 35.9 ...
rnorm(20, m = 42, sd = 6)
data(set20)data(set20)
Small dataset containing 200 samples. The mean is centered on 5 with a standard deviation of 1.
set200set200
The format is: num [1:200] 3.95 5.16 5.32 3.86 3.54 ...
rnorm(200, m = 5, sd = 1)
data(set200)data(set200)
Small dataset containing 50 samples. The mean is centered on 14 with a standard deviation of 3.
set50set50
The format is: num [1:50] 16.61 20.43 7.91 15.19 14.77 ...
rnorm(50, m = 14, sd = 3)
data(set50)data(set50)
This is the function called to work on each individual vector of data.
singleRefLimit(data, dname = "default", out.method = "horn", out.rm = FALSE, RI = "p", CI = "p", refConf = 0.95, limitConf = 0.9, bootStat = "basic")singleRefLimit(data, dname = "default", out.method = "horn", out.rm = FALSE, RI = "p", CI = "p", refConf = 0.95, limitConf = 0.9, bootStat = "basic")
data |
A vector of data points. |
dname |
Name of dataset. |
out.method |
The outlier detection method. Valid options include "horn", "cook", "dixon", and "vanderLoo". |
out.rm |
Remove outliers. If value is TRUE, outliers will be automatically removed prior to calculations. If FALSE (default), outliers will be detected but not removed. |
RI |
Method for reference interval calculations. Valid options include "p" (default) for parametric, "n" for non-parametric, and "r" for robust method. |
CI |
Method for confidence interval calculations. Valid options include "p" for parametric (default), "n" for non-parametric, and "boot" for bootstrapping method. The minimum sample size for non-parametric confidence interval calculations is 120. With smaller samples, bootstrapping methods are used. |
refConf |
Desired coverage for the calculated reference interval. The default is a 95 |
limitConf |
Desired confidence interval level. The default is a 90 confidence interval around the reference interval limits. |
bootStat |
Method for calculating confidence intervals from package boot. Valid arguments include "basic" (basic bootstrap method), "perc" (bootstrap percentile method), "norm" (normal approximation method), "stud" (studentized bootstrap method), and "bca" (adjusted bootstrap percentile method). |
Returns a list of necessary information.
size |
Size of dataset |
dname |
Name of dataset |
out.method |
Method of outlier detection |
out.rm |
Boolean indicating whether outliers are automatically removed |
outliers |
Vector of detected outliers |
methodRI |
Method for reference interval calculations (p, n, or r) |
methodCI |
Method for confidence interval calculations (p, n, boot) |
norm |
Results of running Shapiro-Wilk and Kolmorgorov-Smirnov normacy tests |
refConf |
Desired coverage of reference interval |
limitConf |
Desired confidence interval level |
Ref_Int |
List containing the reference interval and confidence interval values |
Daniel Finnegan
singleRefLimit(set200, out.method = "horn", out.rm = TRUE)singleRefLimit(set200, out.method = "horn", out.rm = TRUE)
Separates data into vectors of outliers and a cleaned subset of the data.
vanderLoo.outliers(data)vanderLoo.outliers(data)
data |
Vector of data values. |
Returns a list containing a vector of outliers and a vector of the cleaned data (subset).
outliers |
A vector of outliers from the data set |
subset |
A vector containing the remaining data, cleaned of outliers |
Requires extremevalues package.
Daniel Finnegan
http://cran.r-project.org/web/packages/extremevalues/extremevalues.pdf
vanderLoo.outliers(set50) vanderLoo.outliers(set200)vanderLoo.outliers(set50) vanderLoo.outliers(set200)