The Joys of P-splines

Update March 6, 2023: files for the P-splines course in Leuven:

This is the companion site for our book Practical Smoothing: The Joys of P-splines, Cambridge University Press (2021). (Here you find the R code for all graphs in the book, pictures of those graphs, as well as supporting functions, data sets and documents.

P-splines are the best smoother on the face of the earth; they combine simplicity with power.

Paul Eilers and Brian Marx

Find the book on the Web

Details are at Cambridge University Press. Amazon link to the book here.

Why P-splines?

Getting Started with P-splines here.


The R package JOPS (Joys Of P-Splines) is available on CRAN and contains a number of support functions for computing with P-splines and for producing and managing graphs. Documentation here.

JOPSplus is a package with several high-level functions for working with P-splines. It is not yet on CRAN. The documentation is here. Download the package here.

Scripts and graphs

The scripts contain R code for producing all the graphs in the book. Their names start with 'f-' and end with ".R" They produce PDF files with the same name, but with the extension ".pdf". The caption of each graph in the book mentions the name of the file that produced it. Most graphs are based on the ggplot2 package. The three-dimensional plots use classical graphics.

We modified the default theme of ggplot2 according to our taste. This theme is named JOPS_theme and it is part of the package.

The individual scripts, with the figures they produce, can be accessed from a dedicated page as PDF documents.

Warning: do not copy and paste the R code from these documents. Most probably the code will get corrupted and not run. The reason is that some characters are coded in an incompatble way in PDF documents. Copy instead from the archive, where all R scripts are collected. We are working on extending each document with a proper link to the correponding R file.


Some of the data sets we use come from R packages. Some others come from different sources. We have included them in our package and documented their properties in the help files.

A little playground for P-splines

You wil also find here a handful of small programs that allow easy interaction with P-splines. Instructions are provided in here. The programs are in a zip archive here

Supporting materials

They are available here and here.


Several sharp-eyed readers detected errors in the book. The list of errata is here.