plf: Basis of a Piecewise Linear Function

Description Usage Arguments Details Value Note Author(s) See Also Examples

View source: R/Mqrcm.R

Description

Generates b1(p), b2(p), … such that, for 0 < p < 1,

θ1*b1(p) + θ2*b2(p) + …

is a piecewise linear function with slopes θ1, θ2, ….

Usage

1
plf(p, knots)

Arguments

p

a numeric vector of values between 0 and 1.

knots

a set of internal knots between 0 and 1. It can be NULL for no internal knots.

Details

This function permits computing a piecewise linear function on the unit interval. A different slope holds between each pair of knots, and the function is continuous at the knots.

Value

A matrix with one row for each element of p, and length(knots) + 1 columns. The knots are returned as attr(, "knots"). Any linear combination of the basis matrix is a piecewise linear function where each coefficient represents the slope in the corresponding sub-interval (see ‘Examples’).

Note

This function is typically used within a call to iMqr. A piecewise linear function can be used to describe how M-quantile regression coefficients depend on the order of the quantile.

Author(s)

Paolo Frumento paolo.frumento@unipi.it

See Also

slp, for shifted Legendre polynomials.

Examples

1
2
3
4
5
6
7
  p <- seq(0,1, 0.1)

  a1 <- plf(p, knots = NULL) # returns p

  a2 <- plf(p, knots = c(0.2,0.7))
  plot(p, 3 + 1*a2[,1] - 1*a2[,2] + 2*a2[,3], type = "l") 
    # intercept = 3; slopes = (1,-1,2)

Mqrcm documentation built on Feb. 2, 2021, 9:06 a.m.