This function is used by the VIM GUI for transformation and standardization of the data.

prepare(
  x,
  scaling = c("none", "classical", "MCD", "robust", "onestep"),
  transformation = c("none", "minus", "reciprocal", "logarithm", "exponential", "boxcox",
    "clr", "ilr", "alr"),
  alpha = NULL,
  powers = NULL,
  start = 0,
  alrVar
)

Arguments

x

a vector, matrix or data.frame.

scaling

the scaling to be applied to the data. Possible values are "none", "classical", MCD, "robust" and "onestep".

transformation

the transformation of the data. Possible values are "none", "minus", "reciprocal", "logarithm", "exponential", "boxcox", "clr", "ilr" and "alr".

alpha

a numeric parameter controlling the size of the subset for the MCD (if scaling="MCD"). See robustbase::covMcd().

powers

a numeric vector giving the powers to be used in the Box-Cox transformation (if transformation="boxcox"). If NULL, the powers are calculated with function car::powerTransform().

start

a constant to be added prior to Box-Cox transformation (if transformation="boxcox").

alrVar

variable to be used as denominator in the additive logratio transformation (if transformation="alr").

Value

Transformed and standardized data.

Details

Transformation:

"none": no transformation is used.

"logarithm": compute the the logarithm (to the base 10).

"boxcox": apply a Box-Cox transformation. Powers may be specified or calculated with the function car::powerTransform().

Standardization:

"none": no standardization is used.

"classical": apply a z-Transformation on each variable by using function scale().

"robust": apply a robustified z-Transformation by using median and MAD.

Author

Matthias Templ, modifications by Andreas Alfons

Examples


data(sleep, package = "VIM")
x <- sleep[, c("BodyWgt", "BrainWgt")]
prepare(x, scaling = "robust", transformation = "logarithm")
#>           BodyWgt     BrainWgt
#>  [1,]  2.29654423  2.065651791
#>  [2,] -0.36479406 -0.341973693
#>  [3,]  0.00384425  0.337397352
#>  [4,] -0.39000221 -0.394162508
#>  [5,]  2.00622319  1.988808266
#>  [6,]  0.34751616  0.833886347
#>  [7,] -1.50523403 -1.442342190
#>  [8,]  1.16954595  0.812428746
#>  [9,] -0.00384425  0.140573701
#> [10,]  0.83068522  1.153063414
#> [11,] -0.62348131 -0.352927979
#> [12,]  1.49208299  1.139036650
#> [13,] -0.54553373 -0.702089671
#> [14,]  1.21685020  1.135654333
#> [15,] -1.14789050 -0.948840510
#> [16,] -0.03265868  0.132130944
#> [17,] -0.43797777 -0.567778126
#> [18,] -0.85136360 -0.440806763
#> [19,] -0.26091911  0.005159582
#> [20,]  0.87301905  0.550618842
#> [21,]  1.53106780  1.308030646
#> [22,]  0.63891332  0.675385949
#> [23,] -1.00579776 -1.013744471
#> [24,]  1.24740764  1.124434445
#> [25,]  0.97832006  1.045217553
#> [26,]  0.72134356  0.689050210
#> [27,] -1.05790948 -0.520242791
#> [28,] -0.35293675 -0.406877653
#> [29,]  1.52646089  1.294696270
#> [30,]  1.02745321  0.786209326
#> [31,]  0.71006820  0.419225234
#> [32,] -1.96659542 -1.713653541
#> [33,] -1.75704133 -1.507246151
#> [34,]  0.88293216  1.544154242
#> [35,] -1.00080057 -0.622653643
#> [36,] -0.27406564 -0.269069705
#> [37,] -1.50523403 -1.339931339
#> [38,] -1.28281320 -1.408413080
#> [39,] -0.20437312 -0.358534177
#> [40,]  0.01394457 -0.166658854
#> [41,]  1.30446866  1.191378447
#> [42,] -0.58668957 -0.038043210
#> [43,]  0.33132958  0.675385949
#> [44,] -0.21894570 -0.147411668
#> [45,]  1.22466589  0.834876573
#> [46,] -0.08777861 -0.126197703
#> [47,]  0.07533343  0.292253871
#> [48,] -0.74964042 -0.785253337
#> [49,]  0.07157342  0.381718343
#> [50,]  0.21473507  0.832893358
#> [51,] -0.45176687 -0.120361733
#> [52,]  0.02246126  0.070063542
#> [53,]  0.45046498  0.619166501
#> [54,]  0.84944951  0.824848129
#> [55,] -0.26307088 -0.114619896
#> [56,] -1.21535185 -1.013744471
#> [57,] -0.39664693 -0.673595570
#> [58,] -0.15523996 -0.120361733
#> [59,] -1.04906038 -0.687557603
#> [60,]  0.06834383  0.431717260
#> [61,]  0.01394457 -0.529255582
#> [62,]  0.05806974 -0.005159582
#> attr(,"scaled:center")
#>   BodyWgt  BrainWgt 
#> 0.5240363 1.2367435 
#> attr(,"scaled:scale")
#>  BodyWgt BrainWgt 
#> 1.436526 1.219976