[R] small spline regression example

Greg Snow Greg.Snow at imail.org
Mon Aug 25 21:48:59 CEST 2008


Are you looking for sample datasets? Or something more?

Sample datasets that work include:

?ethanol
The relationship between E (x-variable) and NOx (y-variable) is very nonlinear, and a polynomial does not fit as well as a spline.

?mtcars
Predict mpg (gas mileage) using weight, hp, or displacement.  The relationship follows a hyperbola (so fitting 1/mpg is fairly linear), but you can start by  fitting a straight line, showing how it misses the main trend, then fit a spline to show the better fit.

Car.test.frame in the rpart package has simmilar data.


You might also take a look at the TkSpline, TkApprox, and loess.demo functions in the TeachingDemos package as well as the ccc and related datasets in that package.

Hope this helps,

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
(801) 408-8111



> -----Original Message-----
> From: r-help-bounces at r-project.org
> [mailto:r-help-bounces at r-project.org] On Behalf Of Erin Hodgess
> Sent: Monday, August 25, 2008 10:52 AM
> To: r-help at r-project.org
> Subject: [R] small spline regression example
>
> Dear R People:
>
> Could someone recommend a small example for spline regression, please?
>
> I would like to show this to my students, step by step.
>
> Thanks in advance,
> Erin
>
>
> --
> Erin Hodgess
> Associate Professor
> Department of Computer and Mathematical Sciences University
> of Houston - Downtown
> mailto: erinm.hodgess at gmail.com
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list