Description Usage Arguments Details Value Examples
Computate a neighbourhood matrix using spatial coordinates.
1 2 3 4 5 6 7 8 9 10 | ## S4 method for signature 'data.frame'
calcW(object, range, method = "euclidean", upper = NULL,
format = "dgCMatrix", row.norm = FALSE, spatial_res = rep(1,ncol(object)),
calcBlockW = FALSE)
## S4 method for signature 'MRIaggr'
calcW(object, range, spatial_res = c(1,1,1), num = NULL,
hemisphere = "both", subset = NULL, upper = TRUE, format = "dgCMatrix",
row.norm = FALSE, calcBlockW = FALSE,
verbose = optionsMRIaggr("verbose"), update.object = FALSE, overwrite = FALSE)
|
object |
a data.frame containing the coordinates of the observations or an |
range |
only distances smaller than |
method |
the distance measure to be used. character. This must be one of |
spatial_res |
a dilatation factor for the coordinates. positive numeric vector of size 3. |
num |
the slices to use. numeric vector or |
hemisphere |
the hemisphere to use. character. |
subset |
the subset of observations to use. positive integer vector or |
upper |
should the entire matrix ( |
format |
the format of the output. Could be |
row.norm |
should the resulting matrix be row-normalized ? |
calcBlockW |
should the partition into disjoint spatial blocks of sites be computed ? logical. |
verbose |
should the execution of the function be traced ? logical. |
update.object |
should the resulting neighbourhood matrix be stored in |
overwrite |
if a neighbourhood matrix is already stored in |
These functions require to have installed the Matrix and the spam package to work.
ARGUMENTS:
Information about the num argument can be found in the details section of initNum.
The range argument cooresponds to the delta argument of the nearest.dist function from the spam package.
Information about the hemisphere argument can be found in the details section of selectContrast.
The row.norm argument is ignored if format is set to "spam".
FUNCTION:
This function relies on the nearest.dist function of the spam package.
Each of the num, hemisphere and subset argument define a subset of the total set of observations.
It is the intersection of all these three subsets that is extracted.
Invisible. A list containing :
[[W]] : a spam or dgCMatrix object.
[[block]] : the output of the calcBlockW function if calcBlockW is set to TRUE, NULL otherwise.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | ## load a MRIaggr object
data("MRIaggr.Pat1_red", package = "MRIaggr")
#### 1- data.frame method ####
coords <- selectCoords(MRIaggr.Pat1_red, num = 1:3, hemisphere = "lesion")
## full W
W <- calcW(object = coords, range = sqrt(2))$W
W[1:10,1:10]
table(spam::rowSums(W))
## full W normalized by row
W <- calcW(object = coords, range = sqrt(2), row.norm = TRUE)$W
W[1:10,1:10]
table(spam::rowSums(W))
## upper W
W <- calcW(object = coords, range = sqrt(2), upper = TRUE)$W
W[1:10,1:10]
#### 2- MRIaggr method ####
## compute W (regular lattice)
W <- calcW(MRIaggr.Pat1_red, range = sqrt(2), upper = NULL, num = 1:3, hemisphere = "lesion")$W
table(spam::rowSums(W > 0))
## compute W (irregular lattice)
W <- calcW(MRIaggr.Pat1_red, range = sqrt(2 * 1.875^2), upper = NULL, num = 1:3,
hemisphere = "lesion", spatial_res=c(1.875, 1.875, 6))$W
table(spam::rowSums(W > 0))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.