q_exp_joint_DZ: Joint Exponential Method for Outlier Detection

Description Usage Arguments Value Examples

View source: R/Main_Functions.R

Description

This function implements the joint exponential method for outlier detection among replicated data. It first fits the aboslute difference Delta between two replicates to an Asymmetric Laplace Distribution using MLE. It then determines whether Delta's Laplace Distribution is Asymmetric or Symmetric and whether it has a significant displacement parameter. Using the exponential parameters derived from the Laplace parameters (see the paper in the citation), this function calculates the joint probability that Delta and Zeta take values more extreme than their observed values for each data point (d and z, respectively). That is, with Laplace displacement parameter theta (which can be zero), this function calculates P(D <= d, z <= Z <= sqrt(2)) if d < theta or P(D >= d, z <= Z <= sqrt(2)) else. We already know 0 <= Z <= sqrt(2).

Usage

1
q_exp_joint_DZ(D, Z, p_theta = 0.05, p_kappa = 0.05)

Arguments

D

The absolute difference (Delta) between two vectors of (positive) replicated data: D = X_1 - X_2

Z

The coefficient of variation (Zeta) between two vectors of (positive) replicated data: Z = sqrt(2) * abs(X_1 - X_2) / (X_1 + X_2)

p_theta

We use the (1-p_theta)*100% two-sided confidence interval for theta in Delta = X_1 - X_2 + theta to determine if there is a significant translation of the absolute difference Delta. If this interval contains 0, then we set theta = 0. We set p_theta = 0.05 by default

p_kappa

We use the (1-p_kappa)*100% two-sided confidence interval for the asymmetry parameter kappa in the Asymmetric Laplace Distribution to which we fit Delta. If this interval for log(kappa) contains 0, then we set kappa = 0 and use a Symmetric Laplace Distribution for Delta. We set p_kappa = 0.05 by default

Value

A numerical vector of equal length to the input D and Z vectors, with the outlier probability q = P((D <= d, z <= Z <= sqrt(2)) | d < theta OR (D >= d, z <= Z <= sqrt(2)) | d >= theta)

Examples

1
2
3
4
5
6
# Assume X_1 and X_2 are positive data vectors of the same length. These are the replicates
data(Sim_GG)
df <- data.frame(X_1=Sim_GG$X_1, X_2=Sim_GG$X_2)
df$D <- df$X_1 - df$X_2
df$Z <- sqrt(2) * abs(df$X_1 - df$X_2) / (df$X_1 + df$X_2)
df$q_exp_j <- q_exp_joint_DZ(df$D, df$Z)

matthew-seth-smith/replicateOutliers documentation built on Jan. 24, 2020, 9:34 p.m.