robust_z: Calculates a robust Z-score that does not have "exploding"...

Description Usage Arguments Value Examples

View source: R/robust_z.R

Description

Calculates a robust Z-score that does not have "exploding" values due to invariant/nearly-invariant vectors

Usage

1
robust_z(x, min = NULL, min.quantile = NULL, by = "row")

Arguments

x

a matrix/table of values to calculate z-scores from

min

a minimum standard deviation to use

min.quantile

a quantile of the non-zero standard deviations to use as a minimum

by

calculate z-scores across "row" or "col"

Value

A matrix of z-scores. If codemin is provided, then that value is used as the minimum standard deviation for calculating z-scores. If codemin is not provided, but codemin.quantile is, then that value is used as the determine the minimum standard deviation for calculating z-scores by choosing the SD at that quantile amongs all the non-zero SDs. If neither is provided, then a standard z-score (code(x - mean(x))/standard deviation(x)) is calculated

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
x <- matrix(c(rnorm(30, mean=10, sd = 1), rnorm(30, mean=10, sd = 0.1)), nrow=10)

# calculate a standard z-score
out <- robust_z(x, by="col")
apply(out, 2, max) # look at max z-score per column

# calculate a robust z-score, using a lower bound of 0.1 for standard deviations
out2 <- robust_z(x, min=0.1, by="col")
apply(out2, 2, max) # look at max z-score per column

# calculate a robust z-score, using a lower bound of 25th percentile for standard deviations
out3 <- robust_z(x, min.quantile=0.25, by="col")
apply(out3, 2, max) # look at max z-score per column

mkumar-rapttx/RAPTR documentation built on July 3, 2021, 10:14 p.m.