fields {fields}R Documentation

fields - tools for spatial data


Fields is a collection of programs for curve and function fitting with an emphasis on spatial data and spatial statistics. The major methods implemented include cubic and thin plate splines, universal Kriging and Kriging for large data sets. One main feature is any covariance function implemented in R code can be used for spatial prediction. Another important feature is that fields will take advantage of compactly supported covariance functions in a seamless way through the spam package. See library( help=fields) for a listing of all the fields contents.

fields stives to have readable and tutorial code. Take a look at the source code for Krig and mKrig to see how things work "under the hood". To load fields with the comments retained in the source use keep.source = TRUE in the library command. We also keep the source on-line: browse the directory for commented source. is a page for html formatted help files. (If you obtain the source version of the package (file ends in .gz) the commented source code is the R subdirectory.)

Major methods

Other noteworthy functions

Generic functions that support the methods

plot - diagnostic plots of fit
summary- statistical summary of fit
print- shorter version of summary
surface- graphical display of fitted surface
predict- evaluation fit at arbitrary points
predictSE- prediction standard errors at arbitrary points.
sim.rf- Simulate a random fields on a 2-d grid.

Getting Started

Try some of the examples from help files for Tps or spatialProcess.

Graphics tips

help( fields.hints) gives some R code tricks for setting up common legends and axes. And has little to do with this package!

Testing See help(fields.tests) for testing fields.

Some fields datasets

DISCLAIMER: The authors can not guarantee the correctness of any function or program in this package.


# some air quality data, daily surface ozone measurements for the Midwest:
y<- ozone2$y[16,] # June 18, 1987

# pixel plot of spatial data
quilt.plot( x,y)
US( add=TRUE) # add US map

fit<- Tps(x,y)
# fits a GCV thin plate smoothing spline surface to ozone measurements.
# Hey, it does not get any easier than this!

summary(fit) #diagnostic summary of the fit 
plot(fit) # four diagnostic plots of fit and residuals.

# quick plot of predicted surface
surface(fit) # contour/image plot of the fitted surface
US( add=TRUE, col="magenta", lwd=2) # US map overlaid
title("Daily max 8 hour ozone in PPB,  June 18th, 1987")

fit2<- spatialProcess( x,y)
# a "Kriging" model. The covariance defaults to a Matern with smoothness 1.0.
# the nugget, sill and range parameters are found by maximum likelihood
# summary, plot, and surface also work for  fit2 !

[Package fields version 8.4-1 Index]