correlation_builder {sim2Dpredictr} | R Documentation |
Build a Correlation Matrix for 2D Spatial Data
Description
This function "builds" a correlation matrix based on user specifications.
Usage
correlation_builder(
corr.structure = "ar1",
im.res,
corr.min = NULL,
neighborhood = "none",
rho = NULL,
phi = NULL,
w = NULL,
h = NULL,
r = NULL,
print.all = FALSE,
round.d = FALSE
)
Arguments
corr.structure |
One of |
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 |
neighborhood |
Defines the neighborhood within which marginal
correlations are non-zero. The default is |
rho |
This is the maximum possible correlation between locations i
and j. For all i,j |
phi |
A scalar value greater than 0 that determines the decay rate of
correlation. This argument is only utilized when |
w , h |
If |
r |
If |
print.all |
If |
round.d |
If |
Value
Returns correlation matrix.
Note
Caution is recommended when using corr.min
or
neighborhood
to set many correlations to 0, as not all
specifications will result in a positive definite matrix. In particular,
sharp drop-offs tend to result in non-positive definite matrices.
Examples
## examples
correlation_builder(corr.structure = "ar1", im.res = c(3, 3), rho = 0.5,
neighborhood = "round", r = 6, print.all = TRUE)
correlation_builder(corr.structure = "exponential", im.res = c(3, 3),
phi = 0.5,
neighborhood = "round", r = 3, print.all = TRUE)
correlation_builder(corr.structure = "CS", im.res = c(3, 3),
rho = 0.5, print.all = TRUE)
## no "true" zeros, but gets close
c.nr <- correlation_builder(corr.structure = "ar1", neighborhood = "none",
corr.min = NULL, im.res = c(15, 15), rho = 0.5)
length(c.nr[c.nr > 0])
min(c.nr)
## set corr.min gives many zero entries; sparser structure
c.r <- correlation_builder(corr.structure = "ar1", neighborhood = "none",
corr.min = 0.01, im.res = c(15, 15), rho = 0.5)
## raw number > 0
length(c.r[c.r > 0])
## proportion > 0
length(c.r[c.r > 0]) / length(c.nr)