Title: | Spatial Prediction Methods In R |
---|---|
Description: | Advanced spatial prediction methods based on various spatial relationships. |
Authors: | Wenbo Lv [aut, cre] , Yangyang Lei [aut] |
Maintainer: | Wenbo Lv <[email protected]> |
License: | GPL-3 |
Version: | 0.1.3.9900 |
Built: | 2024-10-29 06:04:46 UTC |
Source: | https://github.com/SpatLyu/spEcula |
Computationally optimized function for geographically optimal similarity (GOS) model
gos(formula, data = NULL, newdata = NULL, kappa = 0.25, cores = 1)
gos(formula, data = NULL, newdata = NULL, kappa = 0.25, cores = 1)
formula |
A formula of GOS model. |
data |
A data.frame or tibble of observation data. |
newdata |
A data.frame or tibble of prediction variables data. |
kappa |
A numeric value of the percentage of observation locations with high similarity to a prediction location. kappa = 1 - tau, where tau is the probability parameter in quantile operator. The default kappa is 0.25, meaning that 25% of observations with high similarity to a prediction location are used for modelling. |
cores |
positive integer(default is 1). If cores > 1, a 'parallel' package cluster with that many cores is created and used. You can also supply a cluster object. |
A tibble made up of predictions and uncertainties.
Wenbo Lv [email protected]
Song, Y. (2022). Geographically Optimal Similarity. Mathematical Geosciences. doi: 10.1007/s11004-022-10036-8.
## Not run: data(zn) data(grid) g = gos(Zn ~ Slope + Water + NDVI + SOC + pH + Road + Mine, data = zn, newdata = grid, kappa = 0.08,cores = 6) g ## End(Not run)
## Not run: data(zn) data(grid) g = gos(Zn ~ Slope + Water + NDVI + SOC + pH + Road + Mine, data = zn, newdata = grid, kappa = 0.08,cores = 6) g ## End(Not run)
Computationally optimized function for determining the best kappa parameter for the optimal similarity
gos_bestkappa(formula,data = NULL,kappa=seq(0.05,1,0.05), nrepeat = 10,nsplit = 0.5,cores = 1)
gos_bestkappa(formula,data = NULL,kappa=seq(0.05,1,0.05), nrepeat = 10,nsplit = 0.5,cores = 1)
formula |
A formula of GOS model |
data |
A data.frame or tible of observation data |
kappa |
(optional)A numeric vector of the optional percentages of observation locations with high similarity to a prediction location. kappa = 1 - tau, where tau is the probability parameter in quantile operator. kappa = 0.25 means that 25% of observations with high similarity to a prediction location are used for modelling. |
nrepeat |
(optional)A numeric value of the number of cross-validation training times. The default value is 10. |
nsplit |
(optional)The sample training set segmentation ratio,which in |
cores |
positive integer(default is 1). If cores > 1, a 'parallel' package cluster with that many cores is created and used. You can also supply a cluster object. |
A list of the result of the best kappa and the computation process curve.
Wenbo Lv [email protected]
Song, Y. (2022). Geographically Optimal Similarity. Mathematical Geosciences. doi: 10.1007/s11004-022-10036-8.
## Not run: library(dplyr) library(ggplot2) library(ggrepel) data(zn) data(grid) system.time({ b1 = gos_bestkappa(Zn ~ Slope + Water + NDVI + SOC + pH + Road + Mine, data = zn,kappa = c(0.01, 0.05, 0.1, 0.2, 0.5, 1), nrepeat = 2,cores = 1) }) b1$bestkappa b1$plot ## End(Not run)
## Not run: library(dplyr) library(ggplot2) library(ggrepel) data(zn) data(grid) system.time({ b1 = gos_bestkappa(Zn ~ Slope + Water + NDVI + SOC + pH + Road + Mine, data = zn,kappa = c(0.01, 0.05, 0.1, 0.2, 0.5, 1), nrepeat = 2,cores = 1) }) b1$bestkappa b1$plot ## End(Not run)
Spatial grid data of explanatory variables,modified from geosimilarity
package.
grid
grid
grid
: A tibble of grided trace element explanatory variables
with 13132 rows and 12 variables, where the first column is GridID.
car::bcPower
Inverse transform of car::bcPower
inverse_bcPower(z, alpha)
inverse_bcPower(z, alpha)
z |
A numeric vector to be inverse transformed. |
alpha |
Power transformation parameter,which can be got from |
A numeric vector.
Wenbo Lv [email protected]
library(car) library(moments) turbidity = c(1.0, 1.2, 1.1, 1.1, 2.4, 2.2, 2.6, 4.1, 5.0, 10.0, 4.0, 4.1, 4.2, 4.1, 5.1, 4.5, 5.0, 15.2, 10.0, 20.0, 1.1, 1.1, 1.2, 1.6, 2.2, 3.0, 4.0, 10.5) moments::skewness(turbidity) shapiro.test(turbidity) lambdapt = car::powerTransform(turbidity) ttur = car::bcPower(turbidity,lambdapt$lambda) moments::skewness(ttur) shapiro.test(ttur) inverse_bcPower(ttur,lambdapt$lambda)
library(car) library(moments) turbidity = c(1.0, 1.2, 1.1, 1.1, 2.4, 2.2, 2.6, 4.1, 5.0, 10.0, 4.0, 4.1, 4.2, 4.1, 5.1, 4.5, 5.0, 15.2, 10.0, 20.0, 1.1, 1.1, 1.2, 1.6, 2.2, 3.0, 4.0, 10.5) moments::skewness(turbidity) shapiro.test(turbidity) lambdapt = car::powerTransform(turbidity) ttur = car::bcPower(turbidity,lambdapt$lambda) moments::skewness(ttur) shapiro.test(ttur) inverse_bcPower(ttur,lambdapt$lambda)
Spatial prediction based on spatial stratified heterogeneity using sandwich mapping model.
sandwich( sampling, stratification, reporting, sampling_attr, ssh_zone, reporting_id, weight_type = "area" )
sandwich( sampling, stratification, reporting, sampling_attr, ssh_zone, reporting_id, weight_type = "area" )
sampling |
Sampling layer, spatial point vector object which is |
stratification |
Stratification layer, spatial polygon vector object which is |
reporting |
Reporting layer, spatial polygon vector object which is |
sampling_attr |
The |
ssh_zone |
The |
reporting_id |
The |
weight_type |
(optional) Geographic area based on weight( |
A sf
object with estimated mean sandwichest_mean
and standard error sandwichest_standarderror
.
Wenbo Lv [email protected]
Lin, Y., Xu, C., & Wang, J. (2023). sandwichr: Spatial prediction in R based on spatial stratified heterogeneity. Transactions in GIS: TG, 27(5), 1579–1598. https://doi.org/10.1111/tgis.13088
library(sf) simpath = system.file("extdata", "sim.gpkg", package="spEcula") sampling = read_sf(simpath,layer = 'sim_sampling') ssh = read_sf(simpath,layer = 'sim_ssh') reporting = read_sf(simpath,layer = 'sim_reporting') sandwich(sampling = sampling,stratification = ssh,reporting = reporting, sampling_attr = 'Value',ssh_zone = 'X',reporting_id = 'Y', weight_type = 'population') sandwich(sampling = sampling,stratification = ssh,reporting = reporting, sampling_attr = 'Value',ssh_zone = 'X',reporting_id = 'Y', weight_type = 'area')
library(sf) simpath = system.file("extdata", "sim.gpkg", package="spEcula") sampling = read_sf(simpath,layer = 'sim_sampling') ssh = read_sf(simpath,layer = 'sim_ssh') reporting = read_sf(simpath,layer = 'sim_reporting') sandwich(sampling = sampling,stratification = ssh,reporting = reporting, sampling_attr = 'Value',ssh_zone = 'X',reporting_id = 'Y', weight_type = 'population') sandwich(sampling = sampling,stratification = ssh,reporting = reporting, sampling_attr = 'Value',ssh_zone = 'X',reporting_id = 'Y', weight_type = 'area')
Spatial datasets of trace element Zn,modified from geosimilarity
package.
zn
zn
zn
: A tibble of trace element Zn with 885 rows and 12 variables