Learn R Programming

tgp (version 1.1-11)

interp.loess: Lowess 2-d interpolation onto a uniform grid

Description

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.

Usage

interp.loess(x, y, z, gridlen = 40, span = 0.1, ...)

Arguments

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
...
Further arguments to be passed to the loess function

Value

  • The output is a list compatible with the 2-d plotting functions persp, image, and contour, etc.

    The list contains...

  • xVector of with length(x) == gridlen of increasing X grid locations
  • yVector of with length(y) == gridlen of increasing Y grid locations
  • zmatrix of interpolated responses Z = f(X,Y) where z[i,j] contains an estimate of f(x[i],y[j])

Details

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.

References

http://www.ams.ucsc.edu/~rbgramacy/tgp.html

See Also

interp, loess, persp, image, contour

Examples

Run this code
# 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)

Run the code above in your browser using DataLab