prepareComposite | R Documentation |
Prepare distance scores on data in preparation for composite scoring
prepareComposite( object, winsorize = 0, values, better = TRUE, covmat, standardize = TRUE, use.prethreshold = FALSE )
object |
An object of class ‘CompositeData’. |
winsorize |
Whether to winsorize the data or not. Defaults to |
values |
The values to use for winsorization. Optional. If specified, preempts the percentiles given by winsorize. |
better |
Logical indicating whether “better” values than the threshold
are allowed. Defaults to |
covmat |
The covariance matrix to use. If missing, austomatically calculated from the data. |
standardize |
A logical value whether to standardize the data or not.
Defaults to |
use.prethreshold |
A logical value whether to calculate covariance matrix
based on the data after winsorizing, but before applying the threshold.
Defaults to |
An S4 object of class “CompositeReady”.
# this example creates distances for the built in mtcars data # see ?mtcars for more details # The distances are calculated from the "best" in the dataset # First we create an appropriate CompositeData class object # higher mpg & hp are better and lower wt & qsec are better d <- CompositeData(mtcars[, c("mpg", "hp", "wt", "qsec")], thresholds = list(one = with(mtcars, c( mpg = max(mpg), hp = max(hp), wt = min(wt), qsec = min(qsec))) ), higherisbetter = c(TRUE, TRUE, FALSE, FALSE), rawtrans = list( mpg = function(x) x, hp = function(x) x, wt = function(x) x, qsec = sqrt)) # create the distance scores dres <- prepareComposite(d) # see a density plot of the distance scores dres@distanceDensity # regular summary of distance scores summary(dres@distances) # examine covariance matrix round(dres@covmat,2) # cleanup rm(d, dres)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.