basher: Basher Penalty

Description Usage Arguments Details Value Author(s) Examples

View source: R/basher.R

Description

Growth and decay penalties for numeric vectors.

Usage

1
basher(X, A, K)

Arguments

X

A numeric vector.

A

The value at which the penalty starts.

K

The asymptotic ceiling or floor of penalized vector X.

Details

To create a growth penalty, where values greater than A are penalized, K must be greater than A. The growth penalty is K(1-exp(-r(X-M)))) for all values of X greater than A.

To create a decay penalty, where values less than A are penalized, K must be less than A. The decay penalty is K(1+exp(r(X-M))) for all values of X less than A.

Value

basher returns an object of class "basher."

y

The numeric vector X with penalities applied.

A

The value at which the penalty starts.

K

The asymptotic ceiling or floor of penalized vector X (i.e., y).

r

The growth or decay rate of the penalty.

M

An extra parameter set so that y = X at A.

penalty

The type of penalty applied.

Author(s)

Robert P. Bronaugh

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
27
28
  # get the inpatient cost per day, sorted
  data(ipadmits)
  attach(ipadmits)
  ipc = sort(ipadmits$cost)
  plot(ipc,type = "l",col = wash("gry",0.8),lwd=3)
  
  # apply penalty starting 2000. Penalized value not to exceed 4500
  ipc.bash = basher(X = ipc, A = 2000, K = 4500)
  lines(ipc.bash$y,col = wash("blu1",1),lwd = 3)
  plot(ipc,ipc,type = "l",col = wash("gry",0.8),lwd=3)
  lines(ipc,ipc.bash$y,col = wash("blu1",1),lwd = 3)
  
  # apply lower penalty ending at 1500.  Penalized value floor = 500
  ipc.bash = basher(X = ipc, A = 1500, K = 500)
  plot(ipc,type = "l",col = wash("gry",0.8),lwd=3)
  lines(ipc.bash$y,col = wash("blu1",1),lwd = 3)
  plot(ipc,ipc,type = "l",col = wash("gry",0.8),lwd=3)
  lines(ipc,ipc.bash$y,col = wash("blu1",1),lwd = 3)
  
  # combine above ceiling and floor penalties
  ipc.bash = basher(X = ipc, A = 2000, K = 4500)
  ipc.bash = basher(X = ipc.bash$y, A = 1500, K = 500)
  
  plot(ipc,type = "l",col = wash("gry",0.8),lwd=3)
  lines(ipc.bash$y,col = wash("blu1",1),lwd = 3)
  plot(ipc,ipc,type = "l",col = wash("gry",0.8),lwd=3)
  lines(ipc,ipc.bash$y,col = wash("blu1",1),lwd = 3)
  detach(ipadmits)

phalen documentation built on May 29, 2017, 4:22 p.m.

Related to basher in phalen...