setup.spline: Set up splines bases for use with function (g)lmertree.

View source: R/splinetree.R

setup.splineR Documentation

Set up splines bases for use with function (g)lmertree.

Description

setup.spline takes a dataset and spline specification as input, and returns the dataset with spline bases added.

Usage

setup.spline(spline, data, ...)

Arguments

spline

character vector of length 1, describing the spline basis to be created. Currently, functions ns and bs are supported. See Examples.

data

a data.frame containing the variable referred to in spline.

...

additional arguments to be passed to the function specified in spline.

Value

a data.frame with a many rows and columns as data. The spline consists of df basis functions, but is contained in a single column named spline, followed by the name of the predictor variable specified.

See Also

plot.splinetree predict.splinetree lmertree glmertree

Examples

data <- setup.spline("ns(PAR, df = 3)", data = eco)
head(data)
matplot(x = data$PAR[order(data$PAR)], 
        y = data$spline.PAR[order(data$PAR),], type = "l")
data <- setup.spline("bs(PAR, degree = 2, df = 4)", data = eco)
head(data)
matplot(x = data$PAR[order(data$PAR)], 
        y = data$spline.PAR[order(data$PAR),], type = "l")

marjoleinF/gamtree documentation built on July 3, 2024, 9:18 a.m.