glpenalty: Generalized Logistic Penalty

Description Usage Arguments Details Value Examples

View source: R/glpenalty.R

Description

Flexible generalized logistic function.

Usage

1
2
glpenalty(X, x0 = NA, x1 = NA, p = NA, b = NA, type = NA, 
          plotpenalty = TRUE, allowed.error = 0.005, invert = FALSE)

Arguments

X

A numeric vector.

x0

optional: The value(s) where glpentalty is within the allowed.error of 0.

x1

optional: The value(s) where glpenalty is within the allowed.error of 1.

p

optional: A percent of X over which the penalty is applied. p must be between 0 and 1 for single sided glpenalty and between 0 and 0.5 for double sided glpenalty.

b

optional: A positive valued rate at which glpenalty grows or decays.

type

optional: A character value accepting "growth", "decay", or "both"

plotpenalty

If TRUE, the glpenalty is plotted. The default is TRUE.

allowed.error

The allowed difference between glpenalty and 0 or 1 at x0 or x1 respectively. The default is 0.005.

invert

If TRUE, the glpenalty is inverted. The default is FALSE.

Details

The parameter arguments (i.e., the arguements required to parametrize glpenalty) are x0, x1, p, b, and side. Only certian combinations of these parameter arguments are required. If more than the needed number of parameter arguments are given, then glpenalty will use only the first two supplied. The following combinations of parameter arguments are accepted:

1. {x0,x1}: The function will grow (if x0 < x1) or decay (if x0 > x1) between the supplied values. For both growth and decay, supply 2 values to both x0 and x1 where x0[1] < x1[1] < x1[2] < x0[2].

2. {x1,b,side}: The function will grow or decay starting at x1 and at rate b.

3. {p,b,side}: The function will grow or decay starting at p percent of the vector X and at rate b.

Value

Returns the numeric penalty vector.

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
29
30
31
32
33
34
35
  # 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")

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

Related to glpenalty in phalen...