# Penalty.matrix: Penalty matrix for higher order differences In ppls: Penalized Partial Least Squares

## Description

This function computes the matrix that penalizes the higher order differences.

## Usage

 `1` ```Penalty.matrix(m,order = 2) ```

## Arguments

 `m` vector. The jth entry determines the size of the jth block in the penalty term. `order` order of the differences. Default value is `order`=2.

## Details

For the jth entry of the vector `m`, and for the default values `order`=2, the penalty matrix P_j penalizes the second order differences of a vector v of length m[j]. That is

v^T P_j v= ∑_{i=3} ^{m[j]} (Δ v_i) ^2

where

Δ v_i= v_i -2 v_{i-1} + v_{i-2}

is the second order difference. This definition is easily extended to other values of `order`. The final penalty matrix `P` is a block-diagonal matrix with the jth block equal to P_j. More details can be found in Kraemer, Boulesteix, and Tutz (2008).

## Value

penalty matrix of size `sum(m)` x `sum(m)`

## Warning

All entries of the vector `m` must be larger than `order`, as the notion of kth order differences does not make sense for vectors of length k.

Nicole Kraemer

## 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. http://dx.doi.org/10.1016/j.chemolab.2008.06.009

C. de Boor (1978) A Practical Guide to Splines, Springer.

`penalized.pls`

## Examples

 ```1 2``` ``` P<-Penalty.matrix(c(6,4),2) # a more detailed example can be found under penalized.pls() ```

### Example output

```Loading required package: splines