Generate design matrix for periodic restricted cubic spline.
rcs_per(x, knots = NULL, nk = 5, xmin = min(x, na.rm = TRUE),
xmax = max(x, na.rm = TRUE))numerical x values to transform to new basis
vector with locations of the knots of the spline
number of knots, used only if the knots are not specified, overridden otherwise
value of the (theoretical) minimum of x
value of the (theoretical) maximum of x
#' @examples # load example data; see help("viral_east_mediteranean") data("viral_east_mediteranean")
# calculate location of knots to use Knots <- Hmisc::rcspline.eval(x = viral_east_mediteranean$EpiWeek, nk = 5, knots.only = TRUE)
# model viral infections vs weeks model <- glm(RSV ~ rcs_per(EpiWeek, knots = Knots), data = viral_east_mediteranean)
# plot model (with many points, to make it smooth) plot_per_mod(Model = model, XvarName = "EpiWeek", Smooth = TRUE)