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

TRUE to place equidistant knots; FALSE to place quantile knots with clamped boundary knots.

periodic

if TRUE, return domain knot sequence that is sufficient for constructing periodic B-splines; if FALSE, return 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.mgcv)

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)

ZheyuanLi/gps.mgcv documentation built on Sept. 19, 2024, 9:11 p.m.