Learn R Programming

pscore (version 0.4.0)

prepareComposite: Prepare distance scores on data in preparation for composite scoring

Description

Prepare distance scores on data in preparation for composite scoring

Usage

prepareComposite(
  object,
  winsorize = 0,
  values,
  better = TRUE,
  covmat,
  standardize = TRUE,
  use.prethreshold = FALSE
)

Arguments

object

An object of class ‘CompositeData’.

winsorize

Whether to winsorize the data or not. Defaults to FALSE. If not FALSE, the percentile to winsorize at. For example, .01 would be the .01 and the 1 - .01 percentiles.

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 TRUE. #' @param object An DistanceScores class object

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

use.prethreshold

A logical value whether to calculate covariance matrix based on the data after winsorizing, but before applying the threshold. Defaults to FALSE, so that covariances are calculated after thresholds (if any) are applied.

Value

An S4 object of class “CompositeReady”.

Examples

Run this code
# NOT RUN {
# 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)

# }

Run the code above in your browser using DataLab