1  ivdtools Package Overview

ivdtools is an R statistical toolkit for in vitro diagnostic (IVD) reagent evaluation. It provides reproducible workflows for data checking, statistical analysis, result summarization, and visualization. The package covers method comparison, ROC analysis, qualitative agreement, precision, linearity, interference, dilution and spike recovery, C5/C95, measurement uncertainty, commutability, reference-material bias, reference intervals, stability, quality control, curve fitting, analytical sensitivity, outlier and normality assessment, and sample-size calculation. Statistical results should be interpreted together with the pre-specified study protocol, applicable standards, laboratory requirements, and clinical or analytical allowable limits.

1.1 Functional Modules

Module Main entry points Key features
Method comparison mcr() Descriptive statistics, correlation, regression, Bland–Altman, bias, and outliers
Commutability commutability() EP14, EP30, and IFCC commutability assessment
ROC roc() ROC curves, cutoffs, multivariate logistic regression, and prediction
Qualitative analysis raw_to_table(), counts_to_table() Four-fold tables, diagnostic accuracy metrics, Kappa agreement, and McNemar test
Precision precision() Variance components, confidence intervals, outliers, normality, and Sadler precision profiles
Linearity linearity(), linearity_*() Study design, HIGH/LOW preparation, linear/polynomial analysis, weights, ADL, and intervals
Interference interference_*() Replicate planning, paired studies, dose response, and patient-sample comparison
Dilution and spike recovery dilution_recovery(), spike_recovery(), hook_effect() Dilution recovery, spike recovery, and high-dose hook effect
C5/C95 c5_c95() C5/C95 estimation for qualitative reagents from continuous measurements
Measurement uncertainty uncertainty_*() Type A/B, IQC, bias, homogeneity, stability, combination, and propagation
Reference-material bias reference_bias() Bias, measurement-mean uncertainty, and intervals combining reference-material uncertainty
Reference intervals reference_interval() EP28 nonparametric, biweight, type 6, parametric, and Huber intervals
Bottle/lot ANOVA bottle_anova() One-way or nested ANOVA, Tukey HSD, and compact letter display
Stability stability_bias(), stability_regression() Bias, stability regression, time to exceed a limit, stability plans, MKT, and Arrhenius models
Quality control qc_chart(), youden_plot() Levey–Jennings charts, Westgard rules, and Youden plots
Calibration and response curves fit_equation() Weighted and constrained fitting, and model comparison for linear, exponential, 4PLC, 5PLC, and other response equations; not method-comparison linearity assessment
Analytical sensitivity sensitivity_lob() / sensitivity_lod() / sensitivity_loq() Establishment and verification of LoB, LoD, and LoQ
Outliers and distributions outliers_test(), normal_test() Grubbs, ESD, Dixon, IQR, and multiple normality tests
Sample size sample_size_*() Bland–Altman agreement, single-proportion confidence intervals, and one-arm target-value tests

1.2 Design Features

1.2.1 Standalone Workflows

Standalone interfaces complete one task at a time, as in the following examples:

Code
normal_test(dat, col = "candidate")
reference_interval(dat, col = "candidate")

1.2.2 Progressive Workflows

Modules such as method comparison, ROC, qualitative analysis, and precision organize the analysis process with S3 objects:

%%{init: {"theme":"base","themeVariables":{"primaryColor":"#EAF2FB","primaryBorderColor":"#2780E3","primaryTextColor":"#212529","lineColor":"#6C757D","secondaryColor":"#EAF7E6","tertiaryColor":"#FFF4E8","fontSize":"13px"},"flowchart":{"nodeSpacing":18,"rankSpacing":24,"padding":6}}}%%

flowchart LR
    A["Raw data"] --> B["Constructor<br/>create analysis object"]
    B --> C["Analysis methods<br/>accumulate results"]
    C --> D["Updated object"]
    D --> E["summary()"]
    D --> F["plot()"]
    D --> G["predict()<br/>supported modules"]

    classDef input fill:#EAF2FB,stroke:#2780E3,color:#212529
    classDef process fill:#EAF7E6,stroke:#3FB618,color:#212529
    classDef output fill:#F4EEFB,stroke:#9954BB,color:#212529
    class A input
    class B,C process
    class D,E,F,G output

Progressive interfaces must be reassigned:

Code
obj <- analysis_method(obj)

If you call only analysis_method(obj) without obj <-, the new results will not accumulate in the original object.

1.3 Quick Start

The following code is for demonstrating the analysis process only.

1.3.1 Method Comparison

Code
library(ivdtools)

mc <- mcr(
  ivd_mcr_example,
  id = "sid",
  candidate = "test",
  reference = "ref"
)
mc <- describe(mc)
mc <- correlation(mc, method = "pearson")
mc <- regression(mc, method = "deming")
mc <- bland_altman(mc, type = "difference")

summary(mc)
plot(mc, type = "regression")
plot(mc, type = "bland_altman")

1.3.2 ROC

Code
ro <- roc(
  ivd_roc_example,
  cols = c("x1", "x2"),
  reference = "ref",
  positive = 1
)
ro <- describe(ro)
ro <- auc(ro)
ro <- cutoff(ro)
ro <- mlr(ro, cols = c("x1", "x2"), name = "combined")

summary(ro)
plot(ro, curves = "all", cutpoint = "Youden")

1.3.3 Qualitative Agreement

Code
qa <- raw_to_table(
  ivd_qualitative_example,
  candidate = "new",
  reference = "gold",
  id = "id",
  positive = "positive"
)
qa <- describe(qa)
qa <- diagnostics(qa)
qa <- kappa(qa)
qa <- mcnemar(qa)

summary(qa)

1.3.4 Bottle-to-Bottle Difference

Code
ba <- bottle_anova(
  ivd_bottle_example,
  value ~ bottle
)
print(ba)

posthoc <- tukey(ba)
print(posthoc)

1.4 Dependencies

ivdtools primarily depends on ggplot2, ggrepel, VCA, VFP, minpack.lm, nloptr, nls2, nortest, rlang, and ppwdeming.