Pcal.fun | R Documentation |
Compute the penalty matrix associated to a vector containing fixed (non-penalized) parameters and equal-size sub-vectors of penalized spline parameters
Pcal.fun(nfixed, lambda, Pd.x)
nfixed |
the number of fixed (i.e. non-penalized) parameters |
lambda |
a vector of |
Pd.x |
a penalty matrix of size |
A block diagonal penalty matrix of size (nfixed+JK)
given by Blockdiag(diag(0,nfixed
), diag(lambda
).kron.Pd.x
)
Lambert, P. and Gressani, 0. (2023) Penalty parameter selection and asymmetry corrections to Laplace approximations in Bayesian P-splines models. Statistical Modelling. <doi:10.1177/1471082X231181173>. Preprint: <arXiv:2210.01668>.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.