Skip to contents

[Superseded] getRadiiChoices.vario() has been superseded in favour of getRadiiSequence()

Usage

getRadiiChoices.vario(
  numberofradii = 10,
  xydata,
  response,
  basis,
  alpha = 0,
  vgmmodel = "Sph",
  showplots = FALSE,
  distMatrix = NULL,
  ...
)

Arguments

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.

xydata

Data frame containing columns for x and y coordinates. x is assumed to be the first of the two columns

response

vector of response values for use in gstat::variogram. These values should be approximately normally distributed.

basis

character stating whether a 'gaussian' or 'exponential' basis is being used.

alpha

numeric parameter for the gstat::variogram function giving the direction in plane(x,y)

showplots

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

distMatrix

Matrix of distances between data locations and knot locations (n x k). May be Euclidean or geodesic distances. Euclidean distances created using makeDists. This is used as a check to ensure the estimated range parameter does not exceed the maximum distance on the surface. If it does, then the original getRadiiChoices function is used and the distMatrix parameter is a requirement for this.

...

Other parameters for the gstat::variogram function.

Value

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.

Details

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

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<-getRadiiChoices.vario(8, xydata = rad.dat[,c("x.pos", "y.pos")], 
                             response = log(rad.dat$birds +1 ), 
                             basis = "gaussian", 
                             distMatrix = distMats$dataDist)
#> Error in getRadiiChoices.vario(8, xydata = rad.dat[, c("x.pos", "y.pos")],     response = log(rad.dat$birds + 1), basis = "gaussian", distMatrix = distMats$dataDist): object 'r_seq' not found

r_seq
#> Error in eval(expr, envir, enclos): object 'r_seq' not found
attr(r_seq, "vg.fit")
#> Error in eval(expr, envir, enclos): object 'r_seq' not found