Learn R Programming

splinetrials (version 0.1.1)

time_spline_basis: Natural Cubic Spline Basis Matrix for Continuous Time.

Description

Wrapper around splines::ns() with default Boundary.knots of c(0, max(time)).

Usage

time_spline_basis(time, df, Boundary.knots = c(0, max(time)), ...)

Value

A matrix of dimension length(time) * df. See the Value section of splines::ns().

Arguments

time

Continuous time variable, passed directly to splines::ns() as the first argument.

df

Degrees of freedom, passed directly to the df argument of splines::ns().

Boundary.knots

Boundary knots, passed directly to the Boundary.knots argument of splines::ns(). Defaults to c(0, max(time)).

...

Passed to splines::ns().

Details

time_spline() is primarily useful because it can create the spline basis from time and then re-input time into the spline basis to obtain the predictions in one step. Or, it can calculate predictions from a basis supplied to the basis argument.

Examples

Run this code
time_spline_basis(Theoph$Time, df = 3)

Run the code above in your browser using DataLab