find_outliers: Iterative Outlier Detection for Fitted Precision Profile...

View source: R/utils.R

find_outliersR Documentation

Iterative Outlier Detection for Fitted Precision Profile Models.

Description

Identifies outliers in Variance Function Profiling (VFP) models using a two-phase approach. In the first phase, deviance residuals from the fitted model are used to rank observations and select the k most extreme candidates. In the second phase, each candidate is evaluated using a Likelihood Ratio Test (LRT): the candidate is temporarily removed, the best-fitting model is identified on the reduced data, and the same model structure is fitted to the full data. Because the model structures are identical the deviance difference is compared against a chi-squared(1) distribution. The significance level alpha can be adjusted for multiple testing using Bonferroni correction or False Discovery Rate (FDR). The procedure stops at the first candidate that is not confirmed as an outlier.

Usage

find_outliers(
  obj,
  model.no = NULL,
  k = 5,
  alpha = 0.05,
  mult = c("fdr", "bonf", "none"),
  mpos = TRUE,
  plot = FALSE,
  type = c("cv", "sd", "vc"),
  ...
)

Arguments

obj

(object) of class VFP representing a fitted model.

model.no

(integer) model number to use. If NULL, the model with the lowest AIC will be selected automatically.

k

(integer) maximum number of outlier candidates to evaluate.

alpha

(numeric) global significance level for the LRT.

mult

(character) multiplicity adjustment method: "fdr" (default) = False Discovery Rate, "bonf" = Bonferroni, "none" = no adjustment.

mpos

(logical) if TRUE, only positive deviance residuals (observed variance larger than predicted) are considered as candidates and used for multiplicity adjustment. If FALSE, all residuals are considered.

plot

(logical) if TRUE, calls plot_outliers on the result.

type

(character) scale for plotting: "cv" (coefficient of variation), "sd" (standard deviation), or "vc" (variance).

...

additional arguments passed to plot_outliers, e.g. ylim, xlim.

Value

The original VFP object with an additional list element outliers containing:

res

A data.frame with one row per evaluated candidate, including the deviance residual (OCpDRes), the best-fitting model (BestMod), deviances of the full (DevFull) and reduced (DevRed) model, the deviance difference (DiffDev), the critical value (QChisq), the p-value, and a logical flag Outlier.

OutliersRemoved

A data.frame with smooth plotting coordinates of the final VFP model after outlier removal, or NULL if no outliers were found.

ind.out

Integer vector of confirmed outlier indices.

Author(s)

Andre Schuetzenmeister andre.schuetzenmeister@roche.com

Examples

## Not run: 
data(Glucose)
Glucose$DF <- 1
Glucose$Mean <- (Glucose$V1 + Glucose$V2) / 2
Glucose$VC <- (Glucose$V1 - Glucose$V2)^2 / 4
Glucose <- Glucose[which(Glucose$VC > 0), ]
fit <- fit_vfp(Glucose, 1:9)
out <- find_outliers(fit)
out <- find_outliers(fit, plot = TRUE)
out <- find_outliers(fit, plot = TRUE, mult = "none")

## End(Not run)

VFP documentation built on Dec. 4, 2026, 5:09 p.m.