Skip to contents

Compute the geometric z score of each strictly positive value in the sample, relative to the geometric mean and standard deviation typically used in log-normally distributed populations.

Usage

geom.zscore(x, ..., na.rm = FALSE)

Arguments

x

a numeric vector, matrix or data frame

...

additional parameters to be passed to 'geom.mean()'

na.rm

indicate whether or not to remove NAs

Value

a matrix or array of z-scores of length > 1L.

Details

The formula here makes use of the change of base property of logarithms.

Examples

d <- rlnorm(60,1,1.4)
geom.zscore(d)
#>  [1] -0.004560489 -0.539651398  1.361741219  0.158969185 -0.331142688
#>  [6] -0.390898056 -0.953235314  1.378159486 -0.345236294  0.130810501
#> [11]  0.314687832 -0.589678369 -0.199961232  2.275694407 -0.523479536
#> [16] -0.462682505  1.176474055 -1.355346682  0.016460527  0.922986788
#> [21]  0.396898150  0.757618962 -0.674258059  0.811466166  0.873779002
#> [26] -2.051630174  0.587070610 -0.392532961 -0.405477350  0.035364931
#> [31] -0.294441952  0.436331762  1.511137287  0.279048112 -1.413011782
#> [36]  0.814526568  0.116464221  2.440523629 -0.971999060  0.036093848
#> [41]  0.444383190  0.513837283 -0.540760331 -0.853043275  1.172949845
#> [46] -1.086015200  0.045551008  0.456806582  0.627431660  2.014514265
#> [51] -1.902269315 -0.387020984 -2.053615914 -1.028074727  0.486811226
#> [56] -1.932371202  0.703484675 -1.149912313  0.495328409 -0.961098230

x <- matrix(rlnorm(60,1,1.4), ncol = 4)
mapply(geom.zscore, as.data.frame(x))
#>                V1          V2          V3           V4
#>  [1,] -0.42527019 -0.25198581 -0.51256621 -0.680186731
#>  [2,]  0.25823511 -0.34445011  0.67512209  1.129172054
#>  [3,] -0.62737883 -0.54461383 -1.84588701  0.002779358
#>  [4,]  0.71529511  2.18546762  0.39000569 -1.754821280
#>  [5,]  0.75457707 -0.39822449 -1.06707357  0.853593582
#>  [6,] -0.21083032  0.60935630 -1.32651591  0.553511906
#>  [7,] -2.30518444  0.96534780 -0.04741123 -0.389747424
#>  [8,]  0.33280697 -2.42448325  1.22960236  1.256221500
#>  [9,] -1.98280816 -0.62932493  0.74069255 -1.146014407
#> [10,]  1.42792040 -0.84958048 -1.18774926 -0.502926785
#> [11,]  0.40478358  0.77559981  1.30563639  0.763025520
#> [12,]  1.07040735  0.10834256 -0.17515744 -0.720737464
#> [13,]  0.70248255  0.09613211  0.56035627  0.216341825
#> [14,]  0.06192215  0.80837630  1.49819713 -1.309159540
#> [15,] -0.17695835 -0.10595961 -0.23725184  1.728947887