Computes the leverage of each observation in the PC score / IC mixing matrix (U/M) for projection scrubbing. Optionally can threshold the leverage values to flag potential outliers.

leverage(Comps, are_orthogonal = FALSE, median_cutoff = NULL)

Arguments

Comps

The \(n\) by \(Q\) PC score matrix/IC mixing matrix.

are_orthogonal

Can the columns of Comps be assumed to be orthogonal and have a 2-norm of 1? Speeds up the computation.

median_cutoff

The outlier cutoff, in multiples of the median leverage. Default: NULL (do not compute outliers).

Value

A list with entries "meas" (the leverage values), "cut" (the leverage cutoff value) and "flag" (logical vector indicating the outliers). If !is.null(median_cutoff), "cut" and "flag" are omitted.