getRadiiSequence: Function for obtaining a sequence of range parameters for the...

View source: R/getRadiiSequence.R

getRadiiSequenceR Documentation

Function for obtaining a sequence of range parameters for the bivariate CReSS smoother

Description

Function for obtaining a sequence of range parameters for the bivariate CReSS smoother

Usage

getRadiiSequence(
  method = NULL,
  numberofradii = 10,
  distMatrix,
  basis,
  rvin = NULL,
  xydata,
  response,
  alpha = 0,
  vgmmodel = "Sph",
  showplots = FALSE,
  ...
)

Arguments

method

One of "original" or "variogram". The original method is described in Scott-Hayward et al 2013 (reference below) and the variogram method is in the vignette for variogram radii selection

numberofradii

The number of range parameters for SALSA to use when fitting the CReSS smooth. The default is 8. Remember, the more parameters the longer SALSA will take to find a suitable one for each knot location.

distMatrix

Matrix of distances between data locations and knot locations (n x k). May be Euclidean or geodesic distances. Euclidean distances created using makeDists.

basis

character stating whether a 'gaussian' or 'exponential' basis is being used. #' @param rvin Optional if method = "original". Two parameter vector stating the minimum and maximum range of r for a gaussian basis.

xydata

Required if 'method = "variogram". Data frame containing columns for x and y coordinates. x is assumed to be the first of the two columns

response

Required if method = "variogram". Vector of response values for use in gstat::variogram. These values should be approximately normally distributed.

alpha

Optional if method = "variogram". Numeric parameter for the gstat::variogram function giving the direction in plane(x,y)

showplots

(default = FALSE). Optional if method = "variogram". If TRUE the output of gstat::variogram and gstat::fit.variogram are shown.

...

Other parameters for the gstat::variogram function.

Details

The range parameter determines the range of the influence of each knot. Small numbers indicate local influence and large ones, global influence.

Value

  • Original method: This function returns a vector containing a sequence of range parameters.

  • Variogram method: This function returns a vector containing a sequence of range parameters. If an even number of radii is requested, this is reduced by one to give an odd length sequence where the middle number was the best range parameter from the variogram. The outputs of the variogram model can be found in the attributes of the returned object under vg.fit.

Note If the estimated range from the variogram model exceeds the maximum distance in the distance matrix, the sequence reverts to the original method. A warning will be printed and the method used is an attribute in the returned sequence ("Method").

References

Scott-Hayward, L.; M. Mackenzie, C.Donovan, C.Walker and E.Ashe. Complex Region Spatial Smoother (CReSS). Journal of computational and Graphical Statistics. 2013. DOI: 10.1080/10618600.2012.762920

vignette for variogram radii selection

Examples


# load data
data(ns.data.re)
rad.dat <- dplyr::filter(ns.data.re, impact==0, Year==9, MonthOfYear == 3)
# load knot grid data
data(knotgrid.ns)

# make distance matrices for datatoknots and knottoknots
distMats<-makeDists(cbind(rad.dat$x.pos, rad.dat$y.pos), na.omit(knotgrid.ns))
# choose sequence of radii
r_seq<-getRadiiSequence(method = "variogram",
                        numberofradii = 8, 
                        xydata = rad.dat[,c("x.pos", "y.pos")], 
                        response = log(rad.dat$birds +1 ), 
                        basis = "gaussian", 
                        distMatrix = distMats$dataDist)

r_seq
attr(r_seq, "vg.fit")
attr(r_seq, "Method")

 r_seq<-getRadiiSequence(method = "original",
                         numberofradii = 8, 
                         distMatrix = distMats$dataDist, 
                         basis="gaussian")

r_seq
attr(r_seq, "Method")


lindesaysh/MRSea documentation built on April 26, 2024, 2:42 p.m.