slope | R Documentation |
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,
tol = 0.01,
full = FALSE,
decreasing = FALSE
)
x |
numeric or integer: input x values, must be strictly increasing |
y |
numeric: input y values, must be monotone (can be non-strict) and in line with the direction specified by |
outx |
numeric or integer: x values at which slopes are desired (default: same as input values) |
allowZero |
logical: should zero be allowed in the output? Default |
tol |
tolerance level: when |
full |
logical: should a more detailed output be provided? Default |
decreasing |
logical: is input supposed to be monotone decreasing rather than increasing? Default |
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.
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
).
deltaInverse
, which uses this function.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.