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
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 http://www.image.ucar.edu/~nychka/Fields/Source for commented source. http://www.image.ucar.edu/~nychka/Fields/Help/00Index.html 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.)
TpsThin Plate spline regression including GCV and REML estimates for the smoothing parameter.
KrigSpatial process estimation (Kriging) including support for conditional simulation.
The Krig function allows you to supply a covariance function that is written in native R code. See (
stationary.cov) that includes several families of covariances and distance metrics including the Matern and great circle distance.
mKrig(micro Krig) are
fastTpsfast efficient Universal Kriging and spline-like functions, that can take advantage of sparse covariance functions and thus handle very large numbers of spatial locations.
mKrig.MLEfor maximum likelihood estimates of covariance parameters. This function also handles replicate fields assumed to be independent realizations at the same locations.
Other noteworthy functions
vgram.matrixfind variograms for spatial data (and with temporal replications.
cover.designGenerates space-filling designs where the distance function is expresed in R code.
in.polyMany convenient functions for working with image data and rationally (well, maybe reasonably) creating and placing a color scale on an image plot. See also
help(grid.list)for how fields works with grids and
worldfor adding a map quickly.
splintFast 1-D smoothing splines and interpolating cubic splines.
Generic functions that support the methods
plot - diagnostic plots of fit
summary- statistical summary of fit
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.
Try some of the examples from help files for
help( fields.hints) gives some R code tricks for setting up common legends and axes. And has little to do with this package!
help(fields.tests) for testing fields.
Some fields datasets
CO2Global satelite CO2 concentrations (simulated field)
RCMexampleRegional climate model output
lennonImage of John Lennon
COmonthlyMetMonthly mean temperatures and precip for Colorado
RMelevationDigital elevations for the Rocky Mountain Empire
ozone2Daily max 8 hour ozone concentrations for the US midwest for summer 1987.
PRISMelevationDigital elevations for the continental US at approximately 4km resolution
NorthAmericanRainfall50+ year average and trend for summer rainfall at 1700+ stations.
rat.dietSmall paired study on rat food intake over time.
WorldBankCO2Demographic and carbon emission data for 75 countries and for 1999.
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: data(ozone2) x<-ozone2$lon.lat 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 set.panel(2,2) plot(fit) # four diagnostic plots of fit and residuals. set.panel() 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")
Documentation reproduced from package fields, version 6.9.1. License: GPL (>= 2)