create_spline: Create spline matrix

Description Usage Arguments Details Value See Also Examples

View source: R/functions_utils.R

Description

Wrapper function for creating a spline matrix

Usage

1
2
3
4
5
create_spline(x, xrange = NULL, by = 1, df = 1, fn = "ns", ...)

create_spline_matrix(x, df = 1, fn = "ns", ...)

predict_spline(spline, newx, center = FALSE, scale = FALSE)

Arguments

x

Variable values for which spline is to be created.

xrange

Range (min and max) of values to use for creating spline. Only used if x not provided.

by

Interval of generated sequence.

df

Degrees of freedom for spline. If set to 1, then a linear function assumed; otherwise df is passed to fn.

fn

Character string specifying the spline-generating function. Defaults to ns.

...

additional arguments passed to fn.

spline

Spline object from which to predict.

newx

New values for which splines should be generated

center, scale

Should spline values be centered and/or scaled? Default is FALSE. If a vector is provided, it is pased to scale.

Details

Note that predict_spline relies on the existence of a predict generic for the class of spline.

Value

For create_spline, a list containing:

For create_spline_matrix, the matrix of spline values only.

For predict_spline, a matrix of spline values evaluated at newx.

See Also

add_spline_time, sim_update_time_splines

Examples

1
2
3
x_ns <- create_spline(x=1:10, df=3, fn="ns")
x2_ns <- predict(x_ns$spline, newx=seq(0.5, 9.5, by=1))
x2_ns

jpkeller/bercs documentation built on March 24, 2021, 5:36 a.m.