# create a vector of numbers
x = seq.int(1,100)
# specify x near 0 (x0) and x near 1 (x1), growth is computed
glpenalty(x,x0 = 20,x1 = 50)
#How the plot might look when numbers aren't consecutive
glpenalty(sort(sample(x,40)),x0 = 20,x1 = 50)
# decay when x near 0 (x0) is greater than x near 1 (x1)
glpenalty(x,x0 = 50,x1 = 20)
# adjust shrink allowed.error at x0 and x1. Smaller allowed.error
# makes for "steeper" rates of growth or decay.
glpenalty(x,x0 = 50,x1 = 20,allowed.error = 0.0001)
# combine growth and decay by specifying 2 x0 and 2 x1
# growth from 10 to 35 and decay from 50 to 90.
glpenalty(x,x0 = c(10,90),x1 = c(35,50))
# invert
glpenalty(x,x0 = c(10,90),x1 = c(35,50),invert=TRUE)
# specify x1 and growth rate.
glpenalty(x,x1 = 30,b = 0.4, type = "growth")
glpenalty(x,x1 = 20,b = 0.5, type = "decay")
glpenalty(x,x1 = 30,b = 0.3, type = "both")
# specify percent of vector to be penalized
# and growth rate.
glpenalty(x,p = 0.6,b = 0.4, type = "growth")
glpenalty(x,p = 0.6,b = 0.5, type = "decay")
glpenalty(x,p = 0.4,b = 0.3, type = "both")
Run the code above in your browser using DataLab