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.
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"
