Estimate monotone piecewise-linear slopes, with the default behavior forbidding zero slope. This behavior is due to the fact that the function is used to invert confidence intervals using the Delta method. The input interval has to be strictly increasing in x
, and (non-strictly) monotone in y
(increasing or decreasing).
slope(x, y, outx = x, allowZero = FALSE, full = FALSE, decreasing = FALSE)
numeric or integer: input x values, must be strictly increasing
numeric: input y values, must be monotone (can be non-strict) and in line with the direction specified by decreasing
numeric or integer: x values at which slopes are desired (default: same as input values)
logical: should zero be allowed in the output? Default FALSE
logical: should a more detailed output be provided? Default FALSE
(see details under 'Value').
logical: is input supposed to be monotone decreasing rather than increasing? Default FALSE
If full=FALSE
, returns a vector of slopes at the points specified by outx
.
If full=TRUE
, returns a list with slopes at the design point (rawslopes
), the initial guess at output slopes (initial
), and the official final ones (final
).
At design points (i.e., the input x
values), the function takes the average between the left and right slopes (on the edges the inside slope is technically replicated to the outside). If allowZero=FALSE
(default), the algorithm gradually expands the x range over which slope is observed (by increments of one average x
spacing), until a positive slope results. If the input is completely flat in y
and allowZero=FALSE
, the function returns NA
s.
deltaInverse
, which uses this function.