# Radial.Basis: Two dimensional radial and tensor basis functions based on a... In LatticeKrig: Multiresolution Kriging Based on Markov Random Fields

## Description

Two dimensional radial basis and tensor functions based on a Wendland function and using sparse matrix format to reduce the storage.

## Usage

 ``` 1 2 3 4 5 6 7 8 9 10 11 12``` ```Radial.basis(x1, centers, basis.delta, max.points = NULL, mean.neighbor = 50, BasisFunction = "WendlandFunction", distance.type = "Euclidean", verbose = FALSE) Tensor.basis(x1, centers, basis.delta, max.points = NULL, mean.neighbor = 50, BasisFunction = "WendlandFunction", distance.type = "Euclidean") WendlandFunction(d) triWeight(d) ```

## Arguments

 `x1` A matrix of locations to evaluate the basis functions. Each row of `x1` is a location. `centers` A matrix specifying the basis function centers. `d` A vector of distances. `basis.delta` A vector of scale parameters for the basis functions. `max.points` Maximum number of nonzero entries expected for the returned matrix. `distance.type` The distance metric. See `LKrigDistance` for details. `mean.neighbor` Average number of centers that are within delta of each x1 location. For centers on a regular grid this is often easy to estimate. `BasisFunction` A function that will take a nonnegative argument and be zero outside [0,1]. This is applied to distance(s) to generate the basis functions. For tensor basis functions, the function is applied to the distance components for each dimension. `verbose` Print out debugging information if TRUE.

## Details

This function finds the pairwise distances between the points x1 and centers and evaluates the function RadialBasisFunction at these distances scaled by delta. In most applications delta is constant, but a variable delta could be useful for lon/lat regular grids. The Wendland function is for 2 dimensions and smoothness order 2. See `WendlandFunction` for the polynomial form. This code has a very similar function to the fields function `wendland.cov`.

In pseudo R code for delta a scalar `Radial.basis` evaluates as

 ```1 2``` ``` BigD<- rdist( x1,centers) WendlandFunction(BigD/basis.delta) ```

The actual code uses a FORTRAN subroutine to search over distances less than delta and also returns the matrix in sparse format.

The function `Tensor.basis` has similar function as the radial option. The main difference is that a slightly different distance function is used to return the component distances for each dimension. In pseudo R code for delta a scalar and for just two dimensions Tensor.basis evaluates as

 ```1 2 3``` ``` BigD1<- rdist( x1[,1],centers[,1]) BigD2<- rdist( x1[,2],centers[,2]) WendlandFunction(BigD1/basis.delta) *WendlandFunction(BigD1/basis.delta) ```

The function `LKrig.cyl` transforms coordinates on a cylinder, e.g. lon/lat when taken as a Mercator projection, and returns the 3-d coordinates. It is these 3-d coordinates that are used to find distances to define the radial basis functions. For points that are close this "chordal" type distance will be close to the geodesic distance on a cylinder but not identical.

## Value

For `Wendland.basis` a matrix in sparse format with number of rows equal to nrow(x1) and columns equal to nrow(center).

## Author(s)

Doug Nychka

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28``` ```set.seed(12) x<- cbind( runif(100), runif(100)) center<- expand.grid( seq( 0,1,,5), seq(0,1,,5)) # coerce to matrix center<- as.matrix(center) PHI1<- Radial.basis(x, center, basis.delta = .5) PHI2<- Tensor.basis( x, center, basis.delta = .5 ) # similarity of radial and tensor product forms plot( c(0,1.1), c(0,1.1), type="p") for( k in 1:25){ points( PHI1[,k], PHI2[,k]) } # LKrig with a different radial basis function. # data(ozone2) x<-ozone2\$lon.lat y<- ozone2\$y[16,] # Find location that are not 'NA'. # (LKrig is not set up to handle missing observations.) good <- !is.na( y) x<- x[good,] y<- y[good] obj<- LKrig(x,y,NC=30,nlevel=1, alpha=1, lambda=.01, a.wght=5) obj1<- LKrig(x,y,NC=30,nlevel=1, alpha=1, lambda=.01, a.wght=5, BasisFunction="triWeight", overlap=1.8) ```