[R] CV and GCV for finding smoothness parameter

Simon Wood s.wood at bath.ac.uk
Tue Mar 31 22:10:33 CEST 2009

`gam' in package `mgcv' will let you supply any smoothing parameter you want 
(via argument `sp') and will get the  fit and corresponding GCV score for you 
(`gcv.ubre' in the `gam' object). The CV score you'd have to calculate 
yourself, but `influence.gam' will extract the necessary H_ii. See the 
examples in ?smooth.construct for how to use the truncated polynomial basis 
with mgcv:gam.

On Tuesday 31 March 2009 15:22, Nora Velvet wrote:
> I received an assignment that I have to do in R, but I'm absolutely not
> very good at it.
> The task is the following:
> http://www.nabble.com/file/p22804957/question8.jpg
> To do this, we also get the following pieces of code (not in correct
> order): http://www.nabble.com/file/p22804957/hints.jpg
> I'm terrible at this and I'm completely stuck. The model I chose can be
> found in here:
> myknots6 = c(20,24,34)
> p.spline8 = spm(accel ~
> f(times,basis="trunc.poly",degree=2,knots=myknots6))
> Can someone please help me with this task? I'm kind of desperate.
> Thank you!

> Simon Wood, Mathematical Sciences, University of Bath, Bath, BA2 7AY UK
> +44 1225 386603  www.maths.bath.ac.uk/~sw283

More information about the R-help mailing list