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.
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.
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 plug-in methodology
, which, unfortunately, is not
explained in the handout.
The
on-line help for the locpoly
function.
The
on-line help for the dpill
function.
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.
The
on-line help for the smooth.spline
function.
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
The
on-line help for the gam
function.
The
on-line help for the gam.check
function.
The
on-line help for the plot.gam
function.
The
on-line help for the summary.gam
function.
This package is much more ambitious than the other smoothing methods we have discussed. It is the only that does multiple regression models (so-called generalized additive models) of the form
where s1, s2, … sk are arbitrary smooth functions to be estimated.
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 hcv
that does bandwidth selection for kernel smoothing by cross validation.
The
on-line help for the hcv
function.
The
on-line help for the sm.regression
function.
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.