General Instructions
To do each example, just click the Submit
button.
You do not have to type in any R instructions or specify a dataset.
That's already done for you.
Notes
The handout for smoothing is available in Adobe PDF format. Paper copies were handed out in class. No need to print out another if you got one in class.
Kernel Smoother
The kernel smootherksmooth
we used on the previous web page about smoothing
does not do automatic bandwidth selection.
We will discuss another kernel smoother below.
Local Polynomial Smoother
We use for example data the cholostyramine data from Section 7.3 in Efron and Tibshirani.
The KernSmooth
package for R has a function dpill
that does bandwidth selection for local polynomial smoothing by what it
calls direct plugin methodology
, which, unfortunately, is not
explained in the handout.
Help
The online help for the locpoly
function.
The online help for the dpill
function.
Smoothing Spline
We use for example data the cholostyramine data from Section 7.3 in Efron and Tibshirani.
The smooth.spline
function does automatic smoothing parameter
selection by either CV or GCV (the default is GCV) when neither of the
arguments bandwidth
or spar
is supplied.
Help
The online help for the smooth.spline
function.
Another Smoothing Spline
We use for example data the cholostyramine data from Section 7.3 in Efron and Tibshirani.
The mgcv
package for R has a function does
generalized additive models
(the subject of Hastie and Tibshirani, 1990).
The univariate models are either cubic smoothing splines
(explained in the handout) or thin plate splines
(not explained in the handout).
This package has functions

gam
fits generalized additive models 
gam.check
shows diagnostic plots 
summary
prints regression summaries 
plot
prints estimated regression curves with confidence bands
Help
The online help for the gam
function.
The online help for the gam.check
function.
The online help for the plot.gam
function.
The online help for the summary.gam
function.
The online help for the s
function, which implements smooth terms in formulas.
Comments
This package is much more ambitious than the other smoothing methods we have discussed. It is the only that does multiple regression models (socalled generalized additive models) of the form
where s_{1}, s_{2}, … s_{k} are arbitrary smooth functions to be estimated.
Another Kernel Smoother
We use for example data the cholostyramine data from Section 7.3 in Efron and Tibshirani.
The sm
package for R also does kernel smoothing.
It has a function sm.regression
that does kernel smoothing
and a function h.select
that does bandwidth selection for kernel smoothing by cross validation.
Help
The online
help for the h.select
function.
The
online
help for the sm.regression
function.
The online
help for the sm.options
function (describes some arguments
to the other two functions).
Try Two
This function, in violation of R principles, makes its own, somewhat funny looking plot. To get it to make a plot just like the other functions, we need some contortions.
All Together Now