[R] package mgcv inconsistency in help files? cyclic P-spline "cs" not cyclic?
Gavin Simpson
gavin.simpson at ucl.ac.uk
Fri Jun 4 16:33:28 CEST 2010
On Fri, 2010-06-04 at 15:56 +0200, Joris Meys wrote:
> Dear all,
>
> I'm a bit stunned by the behaviour of a gam model using cyclic
> P-spline smoothers. I cannot provide the data, as I have about 61.000
> observations from a time series.
<snip />
>
> I checked the help files ?smooth.terms, and found about 10 lines apart :
>
> bs="cs" specifies a shrinkage version of "cr".
>
> bs="cs" gives a cyclic version of a P-spline.
This is a typo in the help file ?smooth.terms. ?p.spline indicates that
bs = "cp" is what is needed for a cyclic P spline.
In ?smooth.terms
‘bs="cs"’ gives a cyclic version of a P-spline.
should read
‘bs="cp"’ gives a cyclic version of a P-spline.
in in the P Spline section.
By specifying bs = "cs", you weren't getting a cyclic spline at all, it
is a cubic regression spline with shrinkage (so a smooth can potentially
be penalized out of the model entirely during the fitting).
If cc'd the author & maintainer of mgcv (Simon Wood) so that this
doesn't get overlooked amongst the other R-Help traffic.
HTH
G
>
> When I use the (bs="cc") option, I get the results as I want them, so
> I keep with the cyclic cubic splines for now. Yet, I find the
> behaviour of bs="cs" puzzling, and I'm wondering whether I missed
> something, or if this really is an inconsistency in the package.
>
> I currently run mgcv 1.6-1 on R 2.10.1
>
> A small example showing what I experience. Mind you that here x is in
> fact NOT cyclic, whereas in my data I'm sure it has to be :
> y <- rep(1:20,200)
> x <- 1:4000
> DD <- sample(1:360,4000,replace=T)
> TT <- sample(-10:10,4000,replace=T)
> NO <- TT^2 + (10-y+2)^2 + 10*sin(DD*2*pi/360) - 0.002*sqrt(x) +rnorm(4000,0,100)
>
> model <- gam(NO~s(x)+s(y,bs="cs")+s(DD,bs="cs")+s(TT))
> plot(model)
>
> model <- gam(NO~s(x)+s(y,bs="cc")+s(DD,bs="cc")+s(TT))
> plot(model)
>
>
> Cheers
> Joris
>
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Dr. Gavin Simpson [t] +44 (0)20 7679 0522
ECRC, UCL Geography, [f] +44 (0)20 7679 0565
Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/
UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
More information about the R-help
mailing list