prepareComposite: Prepare data to have a composite calculated

Description Usage Arguments Value See Also Examples

View source: R/composite.R

Description

Prepare data to have a composite calculated

Usage

1
prepareComposite(object, covmat, standardize = TRUE)

Arguments

object

An object ready for use

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.

Value

A list of results.

See Also

Other composite: distanceScores; factorComposite; mahalanobisComposite; sumComposite

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 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
# defined by these thresholds
thresholds <- with(mtcars, c(
  mpg = max(mpg),
  hp = max(hp),
  wt = min(wt),
  qsec = min(qsec)))

# higher mpg and hp are better,
# whereas lower wt and qsec are better
dres <- distanceScores(mtcars[, c("mpg", "hp", "wt", "qsec")],
  thresholds = list(thresholds),
  higherisbetter = c(TRUE, TRUE, FALSE, FALSE),
  saveall = TRUE)

# see a density plot of the distance scores
dres$Density

# now prepare to create the composite
# covariance matrix will be calculated from the data
# and data will be standardized to unit variance by default
cprep <- prepareComposite(dres)
# cleanup
rm(thresholds, dres, cprep)

pscore documentation built on May 1, 2019, 6:28 p.m.