Title: | The Second Dimension of Spatial Association |
---|---|
Description: | Most of the current methods explore spatial association using observations at sample locations, which are defined as the first dimension of spatial association (FDA). The proposed concept of the second dimension of spatial association (SDA), as described in Yongze Song (2022) <doi:10.1016/j.jag.2022.102834>, aims to extract in-depth information about the geographical environment from locations outside sample locations for exploring spatial association. |
Authors: | Yongze Song [aut, cre] |
Maintainer: | Yongze Song <[email protected]> |
License: | GPL-2 |
Version: | 3.2 |
Built: | 2024-12-05 07:11:13 UTC |
Source: | CRAN |
Spatial datasets of explanatory variables at a 500-m resolution.
grids
grids
grids
: A data frame of explanatory variables with 68757 rows and 11 columns.
Yongze Song [email protected]
Generating second-dimension variables for a spatial variable
gsdvar( pointlocation, gridlocation, gridvar, distbuf = seq(1, 10, 1), quantileprob = seq(0, 1, 0.1) )
gsdvar( pointlocation, gridlocation, gridvar, distbuf = seq(1, 10, 1), quantileprob = seq(0, 1, 0.1) )
pointlocation |
A matrix or data frame of point locations |
gridlocation |
A matrix or data frame of grid locations |
gridvar |
A matrix or data frame of grid variables |
distbuf |
A vector of distance buffer values |
quantileprob |
A vector of quantile probability values |
A data frame containing the selected variables for the second dimension
data(obs) data(grids) pointlocation <- obs[sample(nrow(obs), 20), c("Lon", "Lat")] gridlocation <- grids[, c("Lon", "Lat")] gridvar <- grids$Elevation system.time({ sdavars <- gsdvar(pointlocation, gridlocation, gridvar, distbuf = c(1, 2, 3), quantileprob = c(0, 0.5, 1)) })
data(obs) data(grids) pointlocation <- obs[sample(nrow(obs), 20), c("Lon", "Lat")] gridlocation <- grids[, c("Lon", "Lat")] gridvar <- grids$Elevation system.time({ sdavars <- gsdvar(pointlocation, gridlocation, gridvar, distbuf = c(1, 2, 3), quantileprob = c(0, 0.5, 1)) })
Spatial datasets of trace elements.
obs
obs
obs
: A data frame of trace elements with 614 rows and 5 variables
Yongze Song [email protected]
Function for removing outliers.
rmvoutlier(x, coef = 2.5)
rmvoutlier(x, coef = 2.5)
x |
A vector of a variale |
coef |
A number of the times of standard deviation. The default value is 2.5. |
Location of outliers in the vector
data("obs") obs$Cr_ppm <- log(obs$Cr_ppm) krm <- rmvoutlier(obs$Cr_ppm) krm
data("obs") obs$Cr_ppm <- log(obs$Cr_ppm) krm <- rmvoutlier(obs$Cr_ppm) krm
Spatial datasets of the first dimension variables of trace elements.
sample_vars_fda
sample_vars_fda
sample_vars_fda
: A list with 8 elements
Yongze Song [email protected]
Spatial datasets of the second dimension variables of trace elements.
sample_vars_sda
sample_vars_sda
sample_vars_sda
: A list with 8 elements
Yongze Song [email protected]
Function for preparing explanatory variables data for SDA-based prediction or the testing data for cross validation
sdapredvars(xlist)
sdapredvars(xlist)
xlist |
A list of the SDA explanatory variables |
A data.frame of variables for prediction or validation
data("obs") data("sample_vars_sda") obs$Cr_ppm <- log(obs$Cr_ppm) krm <- rmvoutlier(obs$Cr_ppm) y <- obs$Cr_ppm[-krm] x <- list(sample_vars_sda[[1]][-krm, 1:11]) kvalidate <- sample(length(y), 0.3*length(y), replace = FALSE) yv <- y[kvalidate] xv <- lapply(x, function(x) x[kvalidate,]) sdaxv <- sdapredvars(xv) sdayxv <- cbind(yv, sdaxv)
data("obs") data("sample_vars_sda") obs$Cr_ppm <- log(obs$Cr_ppm) krm <- rmvoutlier(obs$Cr_ppm) y <- obs$Cr_ppm[-krm] x <- list(sample_vars_sda[[1]][-krm, 1:11]) kvalidate <- sample(length(y), 0.3*length(y), replace = FALSE) yv <- y[kvalidate] xv <- lapply(x, function(x) x[kvalidate,]) sdaxv <- sdapredvars(xv) sdayxv <- cbind(yv, sdaxv)
Function for selecting variables using linear regression
selectvarlm(y, x, ctr.vif = 10)
selectvarlm(y, x, ctr.vif = 10)
y |
A vector of a response variable |
x |
A data.frame of explanatory variables |
ctr.vif |
A number of VIF threshold |
A data.frame of selected variables
data("obs") data("sample_vars_sda") obs$Cr_ppm <- log(obs$Cr_ppm) krm <- rmvoutlier(obs$Cr_ppm) y <- obs$Cr_ppm[-krm] x <- sample_vars_sda$Elevation[-krm, 1:11] sx <- selectvarlm(y, x)
data("obs") data("sample_vars_sda") obs$Cr_ppm <- log(obs$Cr_ppm) krm <- rmvoutlier(obs$Cr_ppm) y <- obs$Cr_ppm[-krm] x <- sample_vars_sda$Elevation[-krm, 1:11] sx <- selectvarlm(y, x)
Function for selecting variables for the second deminsion of spatial association (SDA) model
selectvarsda(y, xlist)
selectvarsda(y, xlist)
y |
A vector of a response variable |
xlist |
A list of the SDA explanatory variables |
A list of the selected the second dimension variables
data("obs") data("sample_vars_sda") obs$Cr_ppm <- log(obs$Cr_ppm) krm <- rmvoutlier(obs$Cr_ppm) y <- obs$Cr_ppm[-krm] x <- list(sample_vars_sda[[1]][-krm, 1:11]) system.time({ # ~0.01s sx <- selectvarsda(y, xlist = x) })
data("obs") data("sample_vars_sda") obs$Cr_ppm <- log(obs$Cr_ppm) krm <- rmvoutlier(obs$Cr_ppm) y <- obs$Cr_ppm[-krm] x <- list(sample_vars_sda[[1]][-krm, 1:11]) system.time({ # ~0.01s sx <- selectvarsda(y, xlist = x) })
Function for fast calculation of the variance inflation factor (VIF)
vif(x)
vif(x)
x |
A data.frame of explanatory variables |
Variance inflation factor (VIF) values of variables
data("sample_vars_sda") x <- sample_vars_sda$Elevation[, sample(55, 10)] vif(x)
data("sample_vars_sda") x <- sample_vars_sda$Elevation[, sample(55, 10)] vif(x)