This function generates the design for a 2-D penalized spline using (almost)
radial basis functions. Use this type of term to account for spatial
variation. Smooth interactions between covariates are often better fitted via
the interactions of lin
and sm
terms, because
they allow a decomposition into (linear and smooth) marginal trends and
(linear-linear, linear-smooth/"varying coefficients", and smooth-smooth)
interactions. This decomposition usually makes no sense for spatial data.
srf(
coords,
K = min(50, sum(nd)/4),
rankZ = 0.999,
centerBase = TRUE,
baseType = c("B", "thinPlate"),
decomposition = c("ortho", "MM", "asIs"),
tol = 1e-10
)
a data.frame
with two columns containing the coordinates
(approximate) number of basis functions in the original basis
(defaults to 50). If baseType ="B"
you can specify a vector giving
the number of marginal basis functions in each direction.
how many eigenvectors to retain from the eigen decomposition: either a number > 3 or the proportion of the sum of eigenvalues the retained eigenvectors must represent at least. Defaults to .999.
project the basis of the penalized part into the complement of the column space of the basis of the unpenalized part? defaults to TRUE
Defaults to "B"
, i.e. a tensor product basis based on
marginal cubic B-splines with ridge penalty (i.e. penalizing deviations
from the constant). Set to "thinPlate"
if cubic thin plate splines
are desired, see note below.
use a (truncated) spectral decomposition of the implied
prior covariance of \(f(x, y)\) for a low rank representation with
orthogonal basis functions and i.i.d. coefficients ("ortho"
), or use
the mixed model reparameterization for non-orthogonal basis functions and
i.i.d. coefficients ("MM"
) or use basis functions as they are with
i.i.d. coefficients ("asIs"
). Defaults to "ortho"
.
count eigenvalues smaller than this as zero
a design matrix for the 2-D spline.
Note that srf()
expects coords
to be a data.frame
within
the larger data.frame
supplied to spikeSlabGAM
in its
data
argument, i.e. coords
is considered a two-dimensional
covariate.
If baseType
is 'thinPlate'
, knot locations for the thin plate
spline basis are chosen via a space-filling algorithm (i.e. medoids returned
by clara
) as suggested in Ruppert/Wand/Carroll, ch.
13.5. Since the thin plate penalty term penalizes deviations from a linear
trend, it is recommended to add marginal linear trends and their interaction
to the model if baseType ="thinPlate"
to improve the fit.
Note that predictions outside the convex hull (sometimes even just close its border) of the original data tend to become rather unstable very quickly.
Ruppert, D., Wand, M.P., Carroll, R.J. (2003). Semiparametric Regression. Cambridge University Press