An assumption underlying ordinary regression is that all observations have the same variance.
This assumption does not always hold, as for the data shown in the figure below (upper panel).
It is clear that the variance increases to the right. It is also clear that the mean of y is not a linear function of x.
Penalized splines can be used to model the mean and variance of y nonparametrically. In order to ensure that the variance is
positive, we model the log-variance by a spline function, rather than the variance itself.
A more detailed discussion of the model and the estimation approach can be found
The LIDAR data shown in the figure below are taken from the book Ruppert et al. (2003).
The file lidar.s shows how to create design matrices for B-splines in R (S-Plus).
When sourced into R, the file creates the input file for ADMB lidar.dat.
You can use lidar.s as a basis for you own spline models.
Fitted mean and standard deviation are shown in the figure below: