Function chooses knots and creates design matrices for fixed and random-effects parts of a spline model for a chosen covariate. Based on code by Crainiceanu et al. (2005) and Zuur et al. (2012). Allows you to choose number of knots or else uses it by the rule given in Crainiceanu et al. (2005). Prepares fixed part of covariate as a quadratic polynomial.
spline.prep(cov, nknot = NA)
A list with the following elements:
The input covariate
The values of the knots
The fixed-effects design matrix
The random-effects design matrix
the covariate, a numeric vector
optional, number of knots
Marc Kéry & Andy Royle
Crainiceanu, C.M., Ruppert, D., & Wand, M.P. (2005) Bayesian analysis for penalized spline regression using WinBUGS. Journal of Statistical Software, 14.
Zuur, A.F., Saveliev, A.A., Ieno, E.N. (2012) Zero-inflated Models and Generalized Linear Mixed Models with R. Highlands Statistics
Kéry, M. & Royle, J.A. (2016) Applied Hierarchical Modeling in Ecology AHM1 - 10.14.