corr_fun {sim2Dpredictr}R Documentation

Specify the Correlation Function between Two Locations

Description

This is primarily for use within correlation builder, and may be altered/expanded to handle more complicated correlation functions if desired.

Usage

corr_fun(
  corr.structure,
  im.res,
  corr.min = NULL,
  rho = NULL,
  phi = NULL,
  neighborhood = "none",
  round.d = FALSE,
  w = NULL,
  h = NULL,
  r = NULL,
  i,
  j,
  k,
  v
)

Arguments

corr.structure

One of "ar1", "exponential", "gaussian", or "CS". Correlations between locations i and j are rho^{d} for corr.structure = "ar1", exp(-phi * d) for corr.structure = "exponential", exp(-phi * d ^ 2) for corr.structure = "gaussian", and rho when corr.structure = "CS". Note that d is the Euclidean distance between locations i and j.

im.res

A vector defining the dimension of spatial data. The first entry is the number of rows and the second entry is the number of columns.

corr.min

Scalar value to specify the minimum non-zero correlation. Any correlations below corr.min are set to 0. Especially for high image resolution using this option can result in a sparser covariance matrix, which may significantly speed up draws when using spam. This option is preferred to using neighborhood and associated arguments when the primary concern is to avoid very small correlations and improve computation efficiency. Default is NULL, which places no restrictions on the correlations.

rho

This is the maximum possible correlation between locations i and j. For all i,j rho MUST be between -1 and 1.

phi

A scalar value greater than 0 that determines the decay of correlation. This argument is only utilized when corr.structure %in% c("exponential", "gaussian").

neighborhood

Defines the neighborhood within which marginal correlations are non-zero. The default is "none", which allows marginal correlations to extend indefinitely. neighborhood = "round" defines a circular neighborhood about locations and neighborhood = "rectangle" defines a rectangular neighborhood about locations.

round.d

If round.d = TRUE, then d is rounded to the nearest whole number.

w, h

If neighborhood = "rectangle" then w and h are the number of locations to the left/right and above/below a location i that define its neighborhood. Any locations outside this neighborhood have have zero correlation with location i.

r

If neighborhood = "round", then if locations i,j are separated by distance d \ge r, the correlation between them is zero.

i, j, k, v

These are the coordinates for the two locations. Location 1 has coordinates (i, j) and location 2 has coordinates (k, v).

Value

A single element vector containing the correlation between spatial locations with indices (i, j) and (k, v).

Examples

## examples
corr_fun(corr.structure = "ar1", im.res = c(3, 3), rho = 0.5,
         neighborhood = "round", r = 6, i = 1, j = 2, k = 2, v = 3)

corr_fun(corr.structure = "ar1", im.res = c(3, 3), rho = 0.5,
         neighborhood = "rectangle", w = 1, h = 1, 
         i = 1, j = 2, k = 2, v = 3)


[Package sim2Dpredictr version 0.1.1 Index]