Learn R Programming

fields (version 1.7.2)

predict.surface: Evaluates a fitted function as a surface object

Description

Evaluates a a fitted model on a 2-D grid keeping any other variables constant. The resulting object is suitable for use with functions for viewing 3-d surfaces.

Usage

predict.surface(out, grid.list=NA, extrap=FALSE, chull.mask, model=NA,
nx=30, ny=30,...)

Arguments

Value

The usual list components for making contour and perspective plots (x,y,z) along with the component containing the grid list.

Details

This function creates the right grid using the grid.list information or the defaults (make.surface.grid), calls the predict function for the object with these points and also adding any extra arguments passed in the ... section, and then reforms the results as a surface object ( as.surface). To determine the what parts of the prediction grid are in the convex hull of the data the function in.poly is used. See the argument inflation in this function is used to include a small margin around the outside of the polygon so that point on convex hull are included. This funny addition is to prevent excluding grid points that fall exactly on the ranges of the data.

See Also

Tps, Krig, predict, grid.list, make.surface.grid, as.surface, surface , in.poly

Examples

Run this code
fit<- Tps( BD[,1:4], BD$lnya)  # fit surface to data 

# evaluate on a grid on two 
# variables holding two fixed  
# default surface and contour plot  
# make grid list
grid.list<- list( KCl="x", MgCl2=mean(BD[,2]),KPO4="y",dNTP=mean(BD[,4]))

out.p<- predict.surface(fit,grid.list, extrap=TRUE) 

surface(out.p) 

set.panel(1,1)

Run the code above in your browser using DataLab