Package 'spEcula'

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-09-29 06:22:32 UTC
Source: https://github.com/SpatLyu/spEcula

Help Index


geographically optimal similarity

Description

Computationally optimized function for geographically optimal similarity (GOS) model

Usage

gos(formula, data = NULL, newdata = NULL, kappa = 0.25, cores = 1)

Arguments

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.

Value

A tibble made up of predictions and uncertainties.

Author(s)

Wenbo Lv [email protected]

References

Song, Y. (2022). Geographically Optimal Similarity. Mathematical Geosciences. doi: 10.1007/s11004-022-10036-8.

Examples

## 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)

function for the best kappa parameter

Description

Computationally optimized function for determining the best kappa parameter for the optimal similarity

Usage

gos_bestkappa(formula,data = NULL,kappa=seq(0.05,1,0.05),
              nrepeat = 10,nsplit = 0.5,cores = 1)

Arguments

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 ⁠(0,1)⁠, default is 0.5.

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.

Value

A list of the result of the best kappa and the computation process curve.

Author(s)

Wenbo Lv [email protected]

References

Song, Y. (2022). Geographically Optimal Similarity. Mathematical Geosciences. doi: 10.1007/s11004-022-10036-8.

Examples

## 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

Description

Spatial grid data of explanatory variables,modified from geosimilarity package.

Usage

grid

Format

grid: A tibble of grided trace element explanatory variables with 13132 rows and 12 variables, where the first column is GridID.


Inverse transform of car::bcPower

Description

Inverse transform of car::bcPower

Usage

inverse_bcPower(z, alpha)

Arguments

z

A numeric vector to be inverse transformed.

alpha

Power transformation parameter,which can be got from car::powerTransform().

Value

A numeric vector.

Author(s)

Wenbo Lv [email protected]

Examples

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)

sandwich mapping model

Description

Spatial prediction based on spatial stratified heterogeneity using sandwich mapping model.

Usage

sandwich(
  sampling,
  stratification,
  reporting,
  sampling_attr,
  ssh_zone,
  reporting_id,
  weight_type = "area"
)

Arguments

sampling

Sampling layer, spatial point vector object which is sf or can be converted to sf object.

stratification

Stratification layer, spatial polygon vector object which is sf or can be converted to sf object.

reporting

Reporting layer, spatial polygon vector object which is sf or can be converted to sf object.

sampling_attr

The attribute column for the sampling point in sampling layer.

ssh_zone

The zone column for the stratification layer.

reporting_id

The id column for the reporting layer.

weight_type

(optional) Geographic area based on weight(area) or indicate human population size(population) , Default is area.

Value

A sf object with estimated mean sandwichest_mean and standard error sandwichest_standarderror.

Author(s)

Wenbo Lv [email protected]

References

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

Examples

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

Description

Spatial datasets of trace element Zn,modified from geosimilarity package.

Usage

zn

Format

zn: A tibble of trace element Zn with 885 rows and 12 variables