smaa.pvf {smaa} | R Documentation |
Compute piece-wise linear partial value functions
Description
Given a set of reference levels and their values, compute a linearly interpolated (piece-wise linear) partial value function.
Usage
smaa.pvf(x, cutoffs, values, outOfBounds="error")
Arguments
x |
Values to compute the PVF for, a numeric vector |
cutoffs |
Reference levels (ascending order) |
values |
Values of the reference levels |
outOfBounds |
What to do when some of the |
Value
A numeric vector the same length as x
.
The values are computed by linear interpolation between the values of the two closest reference levels. This has been implemented in C for a dramatic performance improvement.
Author(s)
Gert van Valkenhoef
Examples
x <- c(50, 90, 100, 10, 40, 101, 120)
values <- smaa.pvf(x,
cutoffs=c(50, 75, 90, 100),
values=c(1, 0.8, 0.5, 0),
outOfBounds="clip")
stopifnot(all.equal(values, c(1.0, 0.5, 0.0, 1.0, 1.0, 0.0, 0.0)))
[Package smaa version 0.3-2 Index]