Skip to contents

Computes the truncated power basis function \((x - \kappa)^k_+\), which is zero for values of x < kappa and equal to \((x - \kappa)^k_+\) otherwise. Commonly used in spline basis construction.

Usage

truncated_power(x, kappa, k)

Arguments

x

A numeric vector of input values.

kappa

A numeric scalar specifying the truncation point.

k

A non-negative integer specifying the exponent.

Value

A numeric vector of the same length as x, with each element transformed by the truncated power function.

Examples

x <- seq(0, 2, by = 0.1)
truncated_power(x, kappa = 1, k = 2)
#>  [1] 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.01 0.04 0.09 0.16
#> [16] 0.25 0.36 0.49 0.64 0.81 1.00