d.central: Central values are desirable

Description Usage Arguments Details Value See Also Examples

View source: R/d.central.R

Description

Maps a numeric variable to a 0-1 scale such that values in the middle of the distribution are desirable.

Usage

1
d.central(x, cut1, cut2, cut3, cut4, des.min = 0, des.max = 1, scale = 1)

Arguments

x

Vector of numeric or integer values.

cut1, cut2, cut3, cut4

Values of the original data that define where the desirability function changes.

des.min, des.max

Minimum and maximum desirability values, defaults to zero and one, respectively.

scale

Controls how steeply the function increases or decreases.

Details

Values less than cut1 and greater than cut4 will have a low desirability. Values between cut2 and cut3 will have a high desirability. Values between cut1 and cut2 and between cut3 and cut4 will have intermediate values. This function is useful when extreme values are undesirable. For example, outliers or values outside of allowable ranges. If cut2 and cut3 are close to each other, this function can be used when a target value is desirable.

Value

Numeric vector of desirability values.

See Also

d.ends

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
set.seed(1)
x <- rnorm(1000, mean=100, sd =5) # generate data
d <- d.central(x, cut1=90, cut2=95, cut3=105, cut4=110, scale=1)

# plot data
hist(x, breaks=30)
# add line
des.line(x, "d.central", des.args=c(cut1=90, cut2=95, cut3=105,
cut4=110, scale=1))

hist(x, breaks=30)
des.line(x, "d.central", des.args=c(cut1=90, cut2=95, cut3=105,
cut4=110, des.min=0.1, des.max=0.95, scale=1.5))

# target value
hist(x, breaks=30)
des.line(x, "d.central", des.args=c(cut1=90, cut2=99.9, cut3=100.1, cut4=110))

stanlazic/desiR documentation built on May 26, 2017, 4:36 p.m.