Gaussian process/kriging models based on simple covariance functions can be written in a very similar form to thin plate and Duchon spline models (e.g. Handcock, Meier, Nychka, 1994), and low rank versions produced by the eigen approximation method of Wood (2003). Kammann and Wand (2003) suggest a particularly simple form of the Matern covariance function with only a single smoothing parameter to estimate, and this class implements this and other similar models.
Usually invoked by an
s(...,bs="gp") term in a
gam formula. Argument
m selects the covariance function, sets the range parameter and any power parameter. If
m is not supplied then it defaults to
NA and the covariance function suggested by Kammann and Wand (2003) along with their suggested range parameter is used. Otherwise
m between 1 and 5 selects the correlation function from respectively, spherical, power exponential, and Matern with kappa = 1.5, 2.5 or 3.5.
m if present specifies the range parameter, with non-positive or absent indicating that the Kammann and Wand estimate should be used.
m can be used to specify the power for the power exponential which otherwise defaults to 1.
1 2 3 4
a smooth specification object, usually generated by a term
a list containing just the data (including any
a list containing any knots supplied for basis setup — in same order and with same names as
Let r>0 be the range parameter, 0<k<=2 and d denote the distance between two points. Then the correlation functions indexed by
1-1.5d/r+0.5(d/r)^3 if d<=r and 0 otherwise.
exp(-d/r)(1+d/r + (d/r)^2/3).
See Fahrmeir et al. (2013) section 8.1.6, for example. Note that setting
r to too small a value will lead to unpleasant results, as most points become all but independent (especially for the spherical model. Note: Wood 2017, Figure 5.20 right is based on a buggy implementation).
The default basis dimension for this class is
M is the null space dimension (dimension of unpenalized function space) and
k.def is 10 for dimension 1, 30 for dimension 2 and 100 for higher dimensions.
This is essentially arbitrary, and should be checked, but as with all penalized regression smoothers, results are statistically
insensitive to the exact choise, provided it is not so small that it forces oversmoothing (the smoother's
degrees of freedom are controlled primarily by its smoothing parameter).
The constructor is not normally called directly, but is rather used internally by
To use for basis setup it is recommended to use
For these classes the specification
object will contain
information on how to handle large datasets in their
xt field. The default is to randomly
subsample 2000 ‘knots’ from which to produce a reduced rank eigen approximation to the full basis,
if the number of unique predictor variable combinations in excess of 2000. The default can be
modified via the
xt argument to
s. This is supplied as a
list with elements
seed containing a number
to use in place of 2000, and the random number seed to use (either can be
missing). Note that the random sampling will not effect the state of R's RNG.
For these bases
knots has two uses. Firstly, as mentioned already, for large datasets
the calculation of the
tp basis can be time-consuming. The user can retain most of the advantages of the
approach by supplying a reduced set of covariate values from which to obtain the basis -
typically the number of covariate values used will be substantially
smaller than the number of data, and substantially larger than the basis dimension,
k. This approach is
the one taken automatically if the number of unique covariate values (combinations) exceeds
The second possibility is to avoid the eigen-decomposition used to find the spline basis altogether and simply use
the basis implied by the chosen knots: this will happen if the number of knots supplied matches the
k. For a given basis dimension the second option is
faster, but gives poorer results (and the user must be quite careful in choosing knot locations).
An object of class
"gp.smooth". In addition to the usual elements of a
smooth class documented under
smooth.construct, this object will contain:
A record of the shift applied to each covariate in order to center it around zero and avoid any co-linearity problems that might otherwise occur in the penalty null space basis of the term.
A matrix of the unique covariate combinations for this smooth (the basis is constructed by first stripping out duplicate locations).
The matrix mapping the smoother parameters back to the parameters of a full GP smooth.
The dimension of the space of functions that have zero wiggliness according to the wiggliness penalty for this term.
the type, range parameter and power parameter defining the correlation function.
Simon N. Wood [email protected]
Fahrmeir, L., T. Kneib, S. Lang and B. Marx (2013) Regression, Springer.
Handcock, M. S., K. Meier and D. Nychka (1994) Journal of the American Statistical Association, 89: 401-403
Kammann, E. E. and M.P. Wand (2003) Geoadditive Models. Applied Statistics 52(1):1-18.
Wood, S.N. (2017) Generalized Additive Models: an introduction with R (2nd ed). CRC/Taylor and Francis
1 2 3 4 5 6 7 8 9 10 11 12 13 14
require(mgcv) eg <- gamSim(2,n=200,scale=.05) attach(eg) op <- par(mfrow=c(2,2),mar=c(4,4,1,1)) b0 <- gam(y~s(x,z,k=50),data=data) ## tps b <- gam(y~s(x,z,bs="gp",k=50),data=data) ## Matern spline default range b1 <- gam(y~s(x,z,bs="gp",k=50,m=c(1,.5)),data=data) ## spherical persp(truth$x,truth$z,truth$f,theta=30) ## truth vis.gam(b0,theta=30) vis.gam(b,theta=30) vis.gam(b1,theta=30) detach(eg)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.