cdiff | R Documentation |
Compute difference matrix used for circular penalities.
cdiff(n)
n |
number of rows (and columns) of the square differencing matrix. |
A square matrix with n
rows and columns.
Paul Eilers
Eilers, P.H.C. and Marx, B.D. (2021). Practical Smoothing, The Joys of P-splines. Cambridge University Press.
Eilers, P.H.C., Marx, B.D., and Durban, M. (2015). Twenty years of P-splines, SORT, 39(2): 149-186.
# Compare standard and circular differencing matrix
n = 8
D1 = diff(diag(n), diff = 2)
D2 = cdiff(n)
oldpar = par(no.readonly = TRUE)
on.exit(par(oldpar))
par(mfrow = c(1, 2))
image(t(D1))
title('Linear differencing matrix')
image(t(D2))
title('Circular differencing matrix')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.