Learn R Programming

cpr (version 0.4.1)

iknots_or_df: Internal Knots or Degrees of Freedom

Description

Check order, degrees of freedom (df) and iknots

Usage

iknots_or_df(x, iknots, df, order)

Value

a numeric vector to use as the internal knots defining a B-spline.

Arguments

x

the support - a numeric vector

iknots

internal knots - a numeric vector

df

degrees of freedom - a numeric value of length 1

order

polynomial order

Details

This is an internal function, not to be exported, and used in the calls for bsplines and bsplineD.

Use iknots preferentially. If iknots are not provided then return the trimmed_quantile for the appropriate df and order

See Also

bsplines, bsplineD, trimmed_quantile

Examples

Run this code

xvec <- runif(600, min = 0, max = 3)

# return the iknots
cpr:::iknots_or_df(x = xvec, iknots = 1:2, df = NULL, order = NULL)

# return the iknots even when the df and order are provided
cpr:::iknots_or_df(x = xvec, iknots = 1:2, df = 56, order = 12)

# return numeric(0) when df <= order (df < order will also give a warning)
cpr:::iknots_or_df(x = xvec, iknots = NULL, df = 6, order = 6)

# return trimmed_quantile when df > order
# probs = (df - order) / (df - order + 1)
cpr:::iknots_or_df(x = xvec, iknots = NULL, df = 10, order = 4)
cpr::trimmed_quantile(xvec, probs = 1:6 / 7)

Run the code above in your browser using DataLab