Function for obtaining a sequence of range parameters for the bivariate CReSS smoother
Source:R/getRadiiSequence.R
getRadiiSequence.Rd
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 ingstat::variogram
. These values should be approximately normally distributed.- alpha
Optional if
method = "variogram"
. Numeric parameter for thegstat::variogram
function giving the direction in plane(x,y)- showplots
(
default = FALSE
). Optional ifmethod = "variogram"
. IfTRUE
the output ofgstat::variogram
andgstat::fit.variogram
are shown.- ...
Other parameters for the
gstat::variogram
function.
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").
Details
The range parameter determines the range of the influence of each knot. Small numbers indicate local influence and large ones, global influence.
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
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
#> [1] 0.0025322476 0.0013154870 0.0008885387 0.0006708204 0.0002961796
#> [6] 0.0001900437 0.0001399078
#> attr(,"Method")
#> [1] "Variogram"
#> attr(,"vg.fit")
#> model psill range
#> 1 Nug 0.5771075 0.000
#> 2 Sph 0.8376254 1054.093
attr(r_seq, "vg.fit")
#> model psill range
#> 1 Nug 0.5771075 0.000
#> 2 Sph 0.8376254 1054.093
attr(r_seq, "Method")
#> [1] "Variogram"
r_seq<-getRadiiSequence(method = "original",
numberofradii = 8,
distMatrix = distMats$dataDist,
basis="gaussian")
r_seq
#> [1] 0.0007538918 0.0006100646 0.0004936767 0.0003994933 0.0003232781
#> [6] 0.0002616033 0.0002116947 0.0001713077
#> attr(,"Method")
#> [1] "Original"
attr(r_seq, "Method")
#> [1] "Original"