OCbasis: Obled-Cruetin Basis Function

View source: R/OCbasis.R

OCbasisR Documentation

Obled-Cruetin Basis Function

Description

Performs a reweighting of radial basis functions ensuring orthonormality.

Usage

OCbasis(
  ...,
  spatialData,
  gbf,
  knots,
  dB = NULL,
  w = NULL,
  nw = NULL,
  nCore = 1L,
  longlat = TRUE
)

Arguments

...

Ignored. Included only to require named inputs.

spatialData

A SpatialPoints object, SpatialPolygons object, or a list of said objects. The source support data. If provided as a list, input dB must be integer or SpatialPolygons.

gbf

A function or character object. The function to use to calculate the radial basis functions of the expansion of the Obled-Creutin eigenfunction. The bi-square, wendland, and radial functions are available through this implementation as 'bisquare', 'wendland' and 'gaussian', respectively. All others must be defined by user. See details for further information.

knots

A matrix or integer. If a matrix, the knots of the radial basis functions. If an integer, the number of knots to generate using fields::cover.design().

dB

NULL, integer, or a SpatialPolygons object defining the spatial region to be sampled when using Monte Carlo estimates. If spatialData is a list of spatial objects, dB must be in an integer specifying the element of spatialData to use as the sampling region or a SpatialPolygons object.

w

A numeric object. The scaling factor for radial basis functions. See details for further information.

nw

An integer object or NULL. The number of MC replicates to generate for estimating the O-C eigenfunctions. If <=0 or NULL, spatialData must be or include SpatialPoints data.

nCore

An integer object or NULL. The number of cores if parallel methods are to be used in the Monte Carlo step.

longlat

A logical object. TRUE if spatialData is longitude/latitude data.

Details

Input 'gbf' allows users to specify a radial basis function beyond the internally implemented bi-square, wendland, and gaussian functions. If user provides a function, the function must use the following formal arguments:

  • crd - the coordinates at which the basis functions are to be evaluated;

  • knots - the knots of the basis functions;

  • w - the scaling factor for the basis function; and

  • ... - an ellipsis to avoid argument errors.

The function must return a matrix of dimension {nrow(crd) x nrow(knots)}.

For completeness, the bi-square functions implemented in the package are of the form

Ψ_{j}(s) = \{1 - (||s - c_j||/w)^2\}^2 \mathrm{I}( ||s-c_j|| ≤q w ).

Note that input 'w' is equivalent to w in the expression above. In addition, if a user were to define an equivalent function inputs s \equiv 'crd' and c_j \equiv 'knots'.

The Wendland basis functions defined as

Ψ_{j}(s) = \{ 1 - d_{j}(s)\}^6 \{35 d_{j}(s)^2 + 18 d_j(s) + 3\}/3 \mathrm{I}( 0 ≤q d_{j} ≤q 1 ),

where

d_{j}(s) = ||s - c_j||/w.

The Gaussian radial basis functions defined as

Ψ_{j}(s) = \exp\{- \frac{1}{2} (||s - c_j||/w)^2\}.

Value

A list containing:

basis

The {nSpatial x r} radial basis function.

OCnorm

The {r x r} Obled Cruetin weighting matrix.

knots

The {nKnots x 2} matrix of knots.

w

The scaling factor used in basis.

Examples


# create 5x5 square 

poly <- raster::rasterToPolygons(raster::raster(nrows = 5, ncols = 5,
                                                xmn = -1.25, xmx = 1.25,
                                                ymn = -1.25, ymx = 1.25,
                                                res = 0.5,
                                                crs = "+proj=longlat +datum=WGS84"))

df <- data.frame("x" = stats::rnorm(n = 25))

dt <- sp::SpatialPolygonsDataFrame(poly, df)

knots <- expand.grid(c(-0.75,0.0,0.75),c(-0.75,0.0,0.75))

OCbasis(spatialData = dt,
        gbf = 'bisquare',
        knots = knots,
        nw = 200L,
        nCore = 1L)

OCbasis(spatialData = dt,
        gbf = 'gaussian',
        knots = knots,
        nw = 200L,
        nCore = 1L)


rcage documentation built on June 7, 2022, 1:07 a.m.

Related to OCbasis in rcage...