This function computes the matrix that penalizes the higher order differences.
Usage
P.penalty(tt, P = c(0, 0, 1))
Details
For example, if P
=c(0,1,2), the function return the penalty matrix
the second order difference of a vector \(tt\). That is $$v^T P_j tt=
\sum_{i=3} ^{n} (\Delta tt_i) ^2$$ where $$\Delta tt_i= tt_i -2 tt_{i-1}
+ tt_{i-2}$$ is the second order difference. More details can be found in
Kraemer, Boulesteix, and Tutz (2008).
References
N. Kraemer, A.-L. Boulsteix, and G. Tutz (2008). Penalized Partial Least Squares with Applications to B-Spline Transformations and Functional Data. Chemometrics and Intelligent Laboratory Systems, 94, 60 - 69. doi:10.1016/j.chemolab.2008.06.009
Author
This version is created by Manuel Oviedo de la Fuente modified the
original version created by Nicole Kramer in ppls
package.
Examples
P.penalty((1:10)/10,P=c(0,0,1))
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#> [1,] 1 -2 1 0 0 0 0 0 0 0
#> [2,] -2 5 -4 1 0 0 0 0 0 0
#> [3,] 1 -4 6 -4 1 0 0 0 0 0
#> [4,] 0 1 -4 6 -4 1 0 0 0 0
#> [5,] 0 0 1 -4 6 -4 1 0 0 0
#> [6,] 0 0 0 1 -4 6 -4 1 0 0
#> [7,] 0 0 0 0 1 -4 6 -4 1 0
#> [8,] 0 0 0 0 0 1 -4 6 -4 1
#> [9,] 0 0 0 0 0 0 1 -4 5 -2
#> [10,] 0 0 0 0 0 0 0 1 -2 1
# a more detailed example can be found under script file