createZforSplines: Create a co-data matrix Z of splines

View source: R/functions_create.R

createZforSplinesR Documentation

Create a co-data matrix Z of splines

Description

Create a co-data matrix Z of spline basis functions for a continuous co-data variable.

Usage

createZforSplines(values, G=10, bdeg=3, index=NULL, p=NULL)

Arguments

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.

Value

A (pxG)-dimensional co-data matrix.

References

See for an introduction on p-splines:

Eilers, P. H., & Marx, B. D. (2021). Practical Smoothing: The Joys of P-splines. Cambridge University Press.

See Also

Use createS to create a difference penalty for p-splines.

Examples

#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)

ecpc documentation built on May 13, 2022, 5:07 p.m.