cdiff {JOPS}R Documentation

Compute a second order circular differencing matrix

Description

Compute difference matrix used for circular penalities.

Usage

cdiff(n)

Arguments

n

number of rows (and columns) of the square differencing matrix.

Value

A square matrix with n rows and columns.

Author(s)

Paul Eilers

References

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.

Examples

# 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')



[Package JOPS version 0.1.19 Index]