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.
smooth.construct.cr.smooth.spec for implementation
a smooth specification object, usually generated by a model term
a list containing just the data required by this term, with names corresponding to
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.
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 round-off precision, i.e.,
S %*% rep(1, N) = rep(1, N),
naive = FALSE with
intercept = TRUE, or will pass constants,
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 time-based smoothing term in a model: see the examples.
N this routine can be very slow. If you are computing models with
N, we highly recommend pre-computing 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
smooth.construct), this object will
a constraint matrix which restricts
the user-specified number of basis vectors, or the computed
the user-specified bandwidth
the full-span computed, normalized basis set, before contiguity is
taken into account. Used by
a logical variable declaring whether or not the input time array was considered to be contiguous by the basis computation procedure.
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. 1055-1096.
Slepian, David (1978) Prolate Spheroidal Wave Functions, Fourier Analysis, and Uncertainty V: the Discrete Case. Bell System Technical Journal. Volume 57, pp. 1371-1429.
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 in-call computation, using K (df) fit1 <- gam(y ~ x + s(t, bs = 'slp', xt = list(K = K)), family = gaussian) # example with in-call computation, using W fit2 <- gam(y ~ x + s(t, bs = 'slp', xt = list(W = W)), family = gaussian)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.