# 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)
Run the code above in your browser using DataLab