30 likes | 204 Views
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 )
E N D
Recitation 2April 23 Natural Cubic Splines Penalized Cubic Regression 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) • by GCV score: sm.spline(x= , y= , cv= FALSE) • R demo 1 NCS -- linearity beyond boundary
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