ns_term: Term for a Basis Matrix for Natural Cubic Splines

View source: R/expansions.R

ns_termR Documentation

Term for a Basis Matrix for Natural Cubic Splines

Description

Term for a Basis Matrix for Natural Cubic Splines

Usage

ns_term(
  x = numeric(),
  df = NULL,
  knots = NULL,
  intercept = FALSE,
  Boundary.knots = range(if (use_log) log(x) else x),
  use_log = FALSE
)

Arguments

x, df, knots, intercept, Boundary.knots

same as ns.

use_log

TRUE if the polynomials should be in the log of the argument.

Value

A list like ns with an additional element called eval to evaluate the basis. See VAJointSurv-terms.

See Also

poly_term, bs_term, weighted_term, and stacked_term.

Examples

vals <- c(0.41, 0.29, 0.44, 0.1, 0.18, 0.65, 0.29, 0.85, 0.36, 0.47)
spline_basis <- ns_term(vals,df = 3)
# evaluate spline basis at 0.5
spline_basis$eval(0.5)
# evaluate first derivative of spline basis at 0.5
spline_basis$eval(0.5, der = 1)

VAJointSurv documentation built on Aug. 14, 2022, 9:05 a.m.