View source: R/functions_create.R
createZforSplines | R Documentation |
Create a co-data matrix Z of spline basis functions for a continuous co-data variable.
createZforSplines(values, G=10, bdeg=3, index=NULL, p=NULL)
values |
A vector with continuous co-data values. |
G |
Number of B-splines. |
bdeg |
Degree of the B-spline basis functions. |
index |
Index of the covariates corresponding to the values supplied. Useful when part of the co-data is missing/seperated and only the non-missing/remaining part should be modelled with splines. |
p |
Number of covariates in total. If not given, taken as length of ‘values’. But in cases where some covariates are left unpenalised, the total number of covariates may be larger. |
A (pxG)-dimensional co-data matrix.
See for an introduction on p-splines:
Eilers, P. H., & Marx, B. D. (2021). Practical Smoothing: The Joys of P-splines. Cambridge University Press.
Use createS
to create a difference penalty for p-splines.
#create co-data with random normally distributed values for 100 covariates values <- rnorm(n=100) #suppose that there is one additional covariate (the first) that should not be modelled ind <- 2:101 p<-101 Z <- createZforSplines(values=values,G=10,index=ind,p=p)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.