Pcal.fun: Function to generate a penalty matrix for additive terms.

View source: R/Pcal_fun.R

Pcal.funR Documentation

Function to generate a penalty matrix for additive terms.

Description

Compute the penalty matrix associated to a vector containing fixed (non-penalized) parameters and equal-size sub-vectors of penalized spline parameters.

Usage

Pcal.fun(nfixed, lambda, Pd.x)

Arguments

nfixed

the number of fixed (i.e. non-penalized) parameters.

lambda

a vector of p penalty parameters where each component is associated to a sub-vector of spline parameters of length J.

Pd.x

a penalty matrix of size J associated to a given sub-vector of spline parameters. .

Value

A block diagonal penalty matrix of size (nfixed+pJ) given by Blockdiag(diag(0,nfixed), diag(lambda).kron.Pd.x).

Author(s)

Philippe Lambert p.lambert@uliege.be

References

Lambert, P. and Kreyenfeld, M. (2025). Time-varying exogenous covariates with frequently changing values in double additive cure survival model: an application to fertility. Journal of the Royal Statistical Society, Series A. <doi:10.1093/jrsssa/qnaf035>

Examples

Dd = diff(diag(1,5),diff=2) ## Difference penalty matrix for a vector of length 5
Pd = t(Dd) %*% Dd ## Penalty matrix of order 2
nfixed = 2 ## 2 unpenalized parameters
## Global penalty matrix when 2 unpenalized parameters and 2 additive terms with
##   2 vectors of 5 P-splines coefficients with lambda values 10 and 100 respectively.
Pcal.fun(nfixed=2,lambda=c(10,100),Pd)

tvcure documentation built on April 12, 2025, 1:58 a.m.