PlaceKnots: Automatically place knots according to data

PlaceKnotsR Documentation

Automatically place knots according to data

Description

Place knots for ordinary B-splines or periodic B-splines using automatic strategies.

Usage

PlaceKnots(x, d, k, domain = NULL, uniform = FALSE, periodic = FALSE)

Arguments

x

observed x-values.

d

B-spline order.

k

number of interior knots.

domain

a vector of two values giving domain interval [a, b]. Will use min(x) and max(x) if not specified.

uniform

if TRUE, place equidistant knots; if FALSE, place quantile knots with clamped boundary knots.

periodic

if TRUE, return the domain knot sequence that is sufficient for constructing periodic B-splines (see pbsDesign); if FALSE, return the full knot sequence that is required for constructing ordinary B-splines.

Value

A vector of K = k + 2d knots for ordinary B-splines, or k + 2 knots for periodic B-splines.

Author(s)

Zheyuan Li zheyuan.li@bath.edu

Examples

require(gps)

x <- rnorm(50)

## uniform knots for uniform cubic B-splines
xt1 <- PlaceKnots(x, d = 4, k = 5, uniform = TRUE)
B1 <- splines::splineDesign(xt1, x, ord = 4)

## clamped quantile knots for clamped non-uniform cubic B-splines
xt2 <- PlaceKnots(x, d = 4, k = 5, uniform = FALSE)
B2 <- splines::splineDesign(xt2, x, ord = 4)

## uniform knots for uniform periodic cubic B-splines
xd1 <- PlaceKnots(x, d = 4, k = 5, uniform = TRUE, periodic = TRUE)
PB1 <- pbsDesign(x, xd1, d = 4)

## quantile knots for non-uniform periodic cubic B-splines
xd2 <- PlaceKnots(x, d = 4, k = 5, uniform = FALSE, periodic = TRUE)
PB2 <- pbsDesign(x, xd2, d = 4)

gps documentation built on Nov. 2, 2023, 6:08 p.m.

Related to PlaceKnots in gps...