Skip to contents

Order matters: flagging outliers first would discard the right tail of a skewed phenotype, so the transform is chosen on all the data and the fences are applied afterwards. Box-Cox is fitted by profile likelihood over a fixed grid rather than an optimiser, which keeps the answer reproducible.

Usage

Pheno2(y, k = 1.5, lambdas = NULL)

Arguments

y

Strictly positive phenotype values.

k

Tukey fence multiplier.

lambdas

Grid of lambda values; -2 to 2 by 0.05 by default.

Value

List with estimate, loglik, n_out, flags, lower, upper, transformed, n.

Details

Formula: y(lambda) = (y^lambda - 1)/lambda, log y at zero, lambda maximising -n/2 log(sigma^2(lambda)) + (lambda - 1) sum log y; then Tukey fences on the transformed values.

References

Tukey, J. W. (1977). Exploratory Data Analysis; Box, G. E. P. & Cox, D. R. (1964). JRSS B 26:211-252, equation (9).

Examples

V <- c(1, 2, 3, 4, 5, 6, 7, 8)
Pheno2(V)
#> $estimate
#> [1] 0.7
#> 
#> $loglik
#> [1] -6.534888
#> 
#> $n_out
#> [1] 0
#> 
#> $flags
#> [1] 0 0 0 0 0 0 0 0
#> 
#> $lower
#> [1] -2.613624
#> 
#> $upper
#> [1] 7.750658
#> 
#> $transformed
#> [1] 0.0000000 0.8921497 1.6538133 2.3414512 2.9788133 3.5787773 4.1493268
#> [8] 4.6958484
#> 
#> $n
#> [1] 8
#> 
#> $method
#> [1] "Box-Cox transform then Tukey fences"
#> 
#> attr(,"class")
#> [1] "morie_rich_result" "list"