Description Usage Arguments Details Value Author(s) Examples
Growth and decay penalties for numeric vectors.
1 | basher(X, A, K)
|
X |
A numeric vector. |
A |
The value at which the penalty starts. |
K |
The asymptotic ceiling or floor of penalized vector |
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
.
basher
returns an object of class "basher
."
y |
The numeric vector |
A |
The value at which the penalty starts. |
K |
The asymptotic ceiling or floor of penalized vector |
r |
The growth or decay rate of the penalty. |
M |
An extra parameter set so that |
penalty |
The type of penalty applied. |
Robert P. Bronaugh
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.