| interp.loess {tgp} | R Documentation |
Use the loess function to interpolate the
two-dimensional x, y, z data onto a uniform grid. The output
produced is an object directly usable by the plotting functions
persp, image,
and contour, etc.
This function is designed as an alternative to the
interp functions from the akima
library.
interp.loess(x, y, z, gridlen = 40, span = 0.1, ...)
x |
Vector of X spatial input locations |
y |
Vector of Y spatial input locations |
z |
Vector of Z responses interpreted as
Z = f(X,Y) |
gridlen |
Size of the interpolated grid to be produced.
The default of gridlen = 40 causes a 40 * 40
grid of X, Y, and Z values to be computed. |
span |
Kernel span argument to the loess
function with default setting span = 0.1 set significantly lower than the
the loess default – see note below. |
... |
Further arguments to be passed to the
loess function |
Uses expand.grid function to produce a uniform
grid of size gridlen with domain equal to the rectangle implied
by X and Y. Then, a loess a smoother
is fit to the data Z = f(X,Y). Finally,
predict.loess is used to predict onto the grid.
The output is a list compatible with the 2-d plotting functions
persp, image,
and contour, etc.
The list contains...
x |
Vector of with length(x) == gridlen of increasing
X grid locations |
y |
Vector of with length(y) == gridlen of increasing
Y grid locations |
z |
matrix of interpolated responses Z = f(X,Y)
where z[i,j] contains an estimate of f(x[i],y[j]) |
As mentioned above, the default span = 0.1 parameter is
signifigantly smaller that the default loess setting.
This asserts a tacit assumption that
the input is densly packed and that the variance in the data is be small.
Such should be the case when the data are output from a tgp regression –
this function was designed specifically for this situation.
For data that is random or sparce, simply choose higher setting,
e.g., the default interp setting of span =
0.75, or a more intermediate setting of span = 0.5 as in the example below
Robert B. Gramacy rbgramacy@ams.ucsc.edu
http://www.ams.ucsc.edu/~rbgramacy/tgp.php
interp, loess,
persp, image, contour
# random data ed <- exp2d.rand() # higher span = 0.5 required becuase the data is sparce # and was generated randomly ed.g <- interp.loess(ed$X[,1], ed$X[,2], ed$Z, span=0.5) # perspective plot persp(ed.g)