Check order, degrees of freedom (df) and iknots
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
Examples
xvec <- runif(600, min = 0, max = 3)
# return the iknots
cpr:::iknots_or_df(x = xvec, iknots = 1:2, df = NULL, order = NULL)
#> [1] 1 2
# return the iknots even when the df and order are provided
cpr:::iknots_or_df(x = xvec, iknots = 1:2, df = 56, order = 12)
#> Warning: Both iknots and df defined, using iknots
#> [1] 1 2
# 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)
#> numeric(0)
# return trimmed_quantile when df > order
# probs = (df - order) / (df - order + 1)
cpr:::iknots_or_df(x = xvec, iknots = NULL, df = 10, order = 4)
#> 14.28571% 28.57143% 42.85714% 57.14286% 71.42857% 85.71429%
#> 0.4576623 0.9097725 1.3163082 1.7251498 2.1546635 2.5640816
cpr::trimmed_quantile(xvec, probs = 1:6 / 7)
#> 14.28571% 28.57143% 42.85714% 57.14286% 71.42857% 85.71429%
#> 0.4576623 0.9097725 1.3163082 1.7251498 2.1546635 2.5640816