tgp (version 2.4-14)

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

Description

Use the loess function to interpolate the two-dimensional x, y, and 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 = c(40,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 in x and y. The default of gridlen = c(40,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

Value

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])

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://bobby.gramacy.com/r_packages/tgp

See Also

interp, loess, persp, image, contour

Examples

Run this code
# NOT RUN {
# random data
ed <- exp2d.rand()

# higher span = 0.5 required because the data is sparse
# 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 DataCamp Workspace