recitation 2 april 23

3
RECITATION 2 APRIL 23 Natural Cubic Splines Penalized Cubic Regression Splines

Upload: cerise

Post on 23-Feb-2016

50 views

Category:

Documents


0 download

DESCRIPTION

Recitation 2 April 23. Natural Cubic Splines P enalized Cubic R egression Splines. Natural Cubic Splines. Cubic splines. sm.spline () in library “ pspline ” How to choose a smoothing parameter by OCV score: sm.spline ( x= , y= , cv= TRUE ) - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Recitation 2 April 23

RECITATION 2APRIL 23

Natural Cubic SplinesPenalized Cubic Regression Splines

Page 2: Recitation 2 April 23

Natural Cubic Splines

• sm.spline() in library “pspline”• How to choose a smoothing parameter

• by OCV score: sm.spline(x= , y= , cv= TRUE)• by GCV score: sm.spline(x= , y= , cv= FALSE)

• R demo 1

Cubic splines

NCS -- linearity beyond boundary

Page 3: Recitation 2 April 23

Penalized Cubic Regression Splines

• gam() in library “mgcv”

• gam( y ~ s(x, bs=“cr”, k=n.knots) , data = dataset)

• Find the optimal smoothing parameter• By default, only select smoothing parameter by GCV score

• R demo 2