Description Usage Arguments Details Value References See Also Examples
Generate the basis matrix for a particular N, W
Slepian sequence
family member, with the additional property that the smoother captures/passes constants
without distortion. Can be quite slow in execution due to the latter property.
Based on smooth.construct.cr.smooth.spec
for implementation
with mgcv
.
1 2 
object 
a smooth specification object, usually generated by a model term 
data 
a list containing just the data required by this term, with names corresponding to

knots 
a list containing any knots supplied for basis setup – should be 
slp
is based on .dpss
, which generates a family of Discrete
Prolate Spheroidal (Slepian) Sequences. These vectors are orthonormal, have alternating
even/odd parity, and form the optimally concentrated basis set for the subspace of
R^N
corresponding to the bandwidth W
. Full details are given
in Slepian (1978). These basis functions have natural boundary conditions, and lack any form of
knot structure. This version is returned for naive = TRUE
.
The dpss
basis vectors can be adapted to provide the additional
useful property of capturing or passing constants perfectly. That is, the smoother matrix
S
formed from the returned rectangular matrix will either reproduce constants
at near roundoff precision, i.e., S %*% rep(1, N) = rep(1, N)
,
for naive = FALSE
with intercept = TRUE
, or will pass constants,
i.e., S %*% rep(1, N) = rep(0, N)
, for naive = FALSE
with intercept = FALSE
.
The primary use is in modeling formula to directly specify a Slepian timebased smoothing term in a model: see the examples.
For large N
this routine can be very slow. If you are computing models with
large N
, we highly recommend precomputing the basis object, then using it
in your models without recomputation. The third example below demonstrates this approach.
An object of class slp.smooth
. In addition to the usual elements of a smooth
class (see smooth.construct
), this object will
contain:
C 
a constraint matrix which restricts 
K 
the userspecified number of basis vectors, or the computed 
W 
the userspecified bandwidth 
fullBasis 
the fullspan computed, normalized basis set, before contiguity is
taken into account. Used by 
contiguous 
a logical variable declaring whether or not the input time array was considered to be contiguous by the basis computation procedure. 
wx 
the “corrected” input time array; if 
Wood S.N. (2006) Generalized Additive Models: An Introduction with R. Chapman and Hall/CRC Press.
Hastie T.J. & Tibshirani, R.J. (1990) Generalized Additive Models. Chapman and Hall.
Thomson, D.J (1982) Spectrum estimation and harmonic analysis. Proceedings of the IEEE. Volume 70, number 9, pp. 10551096.
Slepian, David (1978) Prolate Spheroidal Wave Functions, Fourier Analysis, and Uncertainty V: the Discrete Case. Bell System Technical Journal. Volume 57, pp. 13711429.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18  # Examples using pkg:mgcv
library("mgcv")
library("slp")
N < 730
W < 8 / N
K < 16 # will actually use 15 df as intercept = FALSE
x < rnorm(n = N, sd = 1)
y < x + rnorm(n = N, sd = 2) + 5.0
t < seq(1, N)
# note: all three examples share identical results
# example with incall computation, using K (df)
fit1 < gam(y ~ x + s(t, bs = 'slp', xt = list(K = K)), family = gaussian)
# example with incall computation, using W
fit2 < gam(y ~ x + s(t, bs = 'slp', xt = list(W = W)), family = gaussian)

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
Please suggest features or report bugs in the GitHub issue tracker.
All documentation is copyright its authors; we didn't write any of that.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.