Statistics 5601 (Geyer, Spring 2006) Examples: Bandwidth Selection

Contents

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.

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 plug-in methodology, which, unfortunately, is not explained in the handout.

External Data Entry

Enter a dataset URL :

Help

The on-line help for the locpoly function.

The on-line 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.

External Data Entry

Enter a dataset URL :

Help

The on-line 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

  1. gam fits generalized additive models
  2. gam.check shows diagnostic plots
  3. summary prints regression summaries
  4. plot prints estimated regression curves with confidence bands

External Data Entry

Enter a dataset URL :

Help

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.

Comments

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

y = s1(x1) + s2(x2) + … + sk(xk) + error

where s1, s2, … sk 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 hcv that does bandwidth selection for kernel smoothing by cross validation.

External Data Entry

Enter a dataset URL :

Help

The on-line help for the hcv function.

The on-line help for the sm.regression function.

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.

External Data Entry

Enter a dataset URL :

All Together Now

External Data Entry

Enter a dataset URL :