Package 'geotoolsR'

Title: Tools to Improve the Use of Geostatistic
Description: The basic idea of this package is provides some tools to help the researcher to work with geostatistics. Initially, we present a collection of functions that allow the researchers to deal with spatial data using bootstrap procedure. There are five methods available and two ways to display them: bootstrap confidence interval - provides a two-sided bootstrap confidence interval; bootstrap plot - a graphic with the original variogram and each of the B bootstrap variograms.
Authors: Diogo Francisco Rossoni [aut, cre] , Vinicius Basseto Felix [aut], Ricardo Puziol de Oliveira [ctb]
Maintainer: Diogo Francisco Rossoni <[email protected]>
License: GPL (>= 2)
Version: 1.2.1
Built: 2024-11-01 11:45:34 UTC
Source: CRAN

Help Index


Block bootstrap

Description

Performs a bootstrap based on subdivision of data in blocks

Usage

gboot_block(data,var,model,B,L1,L2)

Arguments

data

object of the class geodata.

var

object of the class variogram.

model

object of the class variomodel.

B

number of the bootstrap that will be performed (default B=1000).

L1

number of cuts in the vertical (L1xL2 blocks).

L2

number of cuts in the horizontal (L1xL2 blocks).

Details

The algorithm for the block bootstrap is an adaptation of the time series bootstrap. Consider that your data presents the second order stationarity, so, we can subdivide them into small blocks. The steps of the algorithm are:

  1. Subdivide the data into L1xL2 blocks;

  2. Realocate each block with probability1L1L2\frac{1}{L1L2} ;

  3. Calculate the new variogram from the new data;

  4. Calculate and save the statistics of interest;

  5. Return to step 2 and repeat the process at least 1000 times.

Value

variogram_boot gives the variogram of each bootstrap.

variogram_or gives the original variogram.

pars_boot gives the estimatives of the nugget, sill, contribution, range and practical range for each bootstrap.

pars_or gives the original estimatives of the nugget, sill, contribution, range and practical range.

Invalid arguments will return an error message.

Author(s)

Diogo Francisco Rossoni [email protected]

Vinicius Basseto Felix [email protected]

References

DAVISON, A.C.; HINKLEY, D. V. Bootstrap Methods and their Application. [s.l.] Cambridge University Press, 1997. p. 582

Examples

# Example 1

## transforming the data.frame in an object of class geodata
data<- as.geodata(soilmoisture)

points(data) ## data visualization

var<- variog(data, max.dist = 140) ## Obtaining the variogram
plot(var)

## Fitting the model
mod<- variofit(var,ini.cov.pars = c(2,80),nugget = 2,cov.model = "sph")
lines(mod, col=2, lwd=2) ##fitted model

## Bootstrap procedure

boot<- gboot_block(data,var,mod,B=10, L1=2, L2=2)
## For better Confidence Interval, try B=1000

gboot_CI(boot,digits = 4) ## Bootstrap Confidence Interval

gboot_plot(boot) ## Bootstrap Variogram plot

# Example 2

## transforming the data.frame in an object of class geodata
data<- as.geodata(NVDI)

points(data) ## data visualization

var<- variog(data, max.dist = 18) ## Obtaining the variogram
plot(var)

## Fitting the model
mod<- variofit(var,ini.cov.pars = c(0.003,6),nugget = 0.003,cov.model = "gaus")
lines(mod, col=2, lwd=2) ##fitted model

## Bootstrap procedure

boot<- boot<- gboot_block(data,var,mod,B=10, L1=2, L2=2)
## For better Confidence interval, try B=1000

gboot_CI(boot,digits = 4) ## Bootstrap Confidence Interval

gboot_plot(boot) ## Bootstrap Variogram plot

Bootstrap Confidence Interval

Description

Provides a two-sided bootstrap confidence interval.

Usage

gboot_CI(x,alpha=0.05,digits=3)

Arguments

x

object generate by functions gboot_block, gboot_cloud, gboot_cross, gboot_solow, gboot_variogram

alpha

significance level (Default=0.05).

digits

number of decimal places.

Details

Examples of this function can be found in gboot_block, gboot_cloud, gboot_cross, gboot_solow, gboot_variogram

Value

Invalid arguments will return an error message.

Author(s)

Diogo Francisco Rossoni [email protected]

Vinicius Basseto Felix [email protected]


Bootstrap of the variogram cloud

Description

Performs a boostrap based on the variogram cloud

Usage

gboot_cloud(data,var,model,B)

Arguments

data

object of the class geodata.

var

object of the class variogram.

model

object of the class variomodel.

B

number of the bootstrap that will be performed (default B=1000).

Details

The variogram cloud is computed by the function variog. It provides all the possible pairs that will generate the classical variogram. The algorithm performs a classical bootstrap in each lag of the variogram. The steps are:

  1. Calculate the variogram cloud;

  2. Obtain the number of lags (See details in variog: defining the bins);

  3. Sample with replacement in each lag;

  4. Create a new variogram using the average of all pairs in each lag;

  5. Calculate and save the statistics of interest;

  6. Return to step 3 and repeat the process at least 1000 times.

Value

variogram_boot gives the variogram of each bootstrap.

variogram_or gives the original variogram.

pars_boot gives the estimatives of the nugget, sill, contribution, range and practical range for each bootstrap.

pars_or gives the original estimatives of the nugget, sill, contribution, range and practical range.

Invalid arguments will return an error message.

Author(s)

Diogo Francisco Rossoni [email protected]

Vinicius Basseto Felix [email protected]

Examples

# Example 1

## transforming the data.frame in an object of class geodata
data<- as.geodata(soilmoisture)

points(data) ## data visualization

var<- variog(data, max.dist = 140) ## Obtaining the variogram
plot(var)

## Fitting the model
mod<- variofit(var,ini.cov.pars = c(2,80),nugget = 2,cov.model = "sph")
lines(mod, col=2, lwd=2) ##fitted model

## Bootstrap procedure

boot<- gboot_cloud(data,var,mod,B=10)
## For better Confidence interval, try B=1000

gboot_CI(boot,digits = 4) ## Bootstrap Confidence Interval

gboot_plot(boot) ## Bootstrap Variogram plot

# Example 2

## transforming the data.frame in an object of class geodata
data<- as.geodata(NVDI)

points(data) ## data visualization

var<- variog(data, max.dist = 18) ## Obtaining the variogram
plot(var)

## Fitting the model
mod<- variofit(var,ini.cov.pars = c(0.003,6),nugget = 0.003,cov.model = "gaus")
lines(mod, col=2, lwd=2) ##fitted model

## Bootstrap procedure

boot<- gboot_cloud(data,var,mod,B=10)
## For better Confidence interval, try B=1000

gboot_CI(boot,digits = 4) ## Bootstrap Confidence Interval

gboot_plot(boot) ## Bootstrap Variogram plot

Cross-validation bootstrap

Description

Performs a boostrap based on error from the cross-validation

Usage

gboot_cross(data,var,model,B)

Arguments

data

object of the class geodata.

var

object of the class variogram.

model

object of the class variomodel.

B

number of the bootstrap that will be performed (default B=1000).

Details

We can define the error of prediction by ϵ(si)=Z(si)Z^(si)\epsilon({s_i})=Z({s_i})-\hat Z({s_i}), where Z^(si)\hat Z({s_i}) are obtained from cross-validation. The steps of the algorithm are:

  1. Set si=si{s_i}^*={s_i};

  2. Obtain Z^(si)\hat Z({s_i}) from Z^(si)=jin1λjZ(sj)\hat Z({s_i})=\sum\limits_{j \ne i}^{n - 1}{{\lambda _j}Z({s_j})};

  3. Calculate ϵ(si)=Z(si)Z^(si)\epsilon({s_i})=Z({s_i})-\hat Z({s_i})

  4. Sample with replacement ϵ(si)\epsilon^*(s_i) from ϵ(si)ϵˉ(si)\epsilon (s_i) - \bar \epsilon (s_i);

  5. The new data will be Z(si)=Z^(si)+ϵ(si)Z^*({s_i})=\hat Z({s_i})+ \epsilon^*(s_i);

  6. Calculate the new variogram;

  7. Calculate and save the statistics of interest;

  8. Return to step 4 and repeat the process at least 1000 times.

Value

variogram_boot gives the variogram of each bootstrap.

variogram_or gives the original variogram.

pars_boot gives the estimatives of the nugget, sill, contribution, range and practical range for each bootstrap.

pars_or gives the original estimatives of the nugget, sill, contribution, range and practical range.

Invalid arguments will return an error message.

Author(s)

Diogo Francisco Rossoni [email protected]

Vinicius Basseto Felix [email protected]

Examples

# Example 1

## transforming the data.frame in an object of class geodata
data<- as.geodata(soilmoisture)

points(data) ## data visualization

var<- variog(data, max.dist = 140) ## Obtaining the variogram
plot(var)

## Fitting the model
mod<- variofit(var,ini.cov.pars = c(2,80),nugget = 2,cov.model = "sph")
lines(mod, col=2, lwd=2) ##fitted model

## Bootstrap procedure

boot<- gboot_cross(data,var,mod,B=10)
## For better Confidence interval, try B=1000

gboot_CI(boot,digits = 4) ## Bootstrap Confidence Interval

gboot_plot(boot) ## Bootstrap Variogram plot

# Example 2

## transforming the data.frame in an object of class geodata
data<- as.geodata(NVDI)

points(data) ## data visualization

var<- variog(data, max.dist = 18) ## Obtaining the variogram
plot(var)

## Fitting the model
mod<- variofit(var,ini.cov.pars = c(0.003,6),nugget = 0.003,cov.model = "gaus")
lines(mod, col=2, lwd=2) ##fitted model

## Bootstrap procedure

boot<- gboot_cross(data,var,mod,B=10)
## For better Confidence interval, try B=1000

gboot_CI(boot,digits = 4) ## Bootstrap Confidence Interval

gboot_plot(boot) ## Bootstrap Variogram plot

Bootstrap plot

Description

A graphic with the original variogram and each of the B bootstrap variograms.

Usage

gboot_plot(x)

Arguments

x

object generate by functions gboot_block, gboot_cloud, gboot_cross, gboot_solow, gboot_variogram

Details

Examples of this function can be found in gboot_block, gboot_cloud, gboot_cross, gboot_solow, gboot_variogram

Value

Invalid arguments will return an error message.

Author(s)

Diogo Francisco Rossoni [email protected]

Vinicius Basseto Felix [email protected]


Solow bootstrap

Description

Performs a spatial boostrap proposed by Solow(1985).

Usage

gboot_solow(data,var,model,B)

Arguments

data

object of the class geodata.

var

object of the class variogram.

model

object of the class variomodel.

B

number of the bootstrap that will be performed (default B=1000).

Details

The basic idea involves transforming correlated observation to uncorrelated quantities, forming a bootstrap sample from these quantities, and transforming back to a bootstrap sample form the original observations (SOLOW, 1985). Suppose that ZnZ_n is an nn vector of observations from a realization of a second-order stationary random process, Z(si)Z(s_i), and the covariance matrix for ZnZ_n is CC. Suppose further that E(Zn)=0nE(Z_n)={0_n}, where 0n{0_n} is an nn vector of zeroes. In practice ZnZ_n can be centered by subtracting an estimate of the stationary mean from each observation. So, the steps of the algorithm are:

  1. Obtain CC;

  2. Apply the Cholesky decomposition in CC, obtaining C=LLtC=LL^t, where LL is lower triangular;

  3. Obtain Un=L1ZnU_n=L^{-1}Z_n;

  4. Sample with replacement Un{U^*}_n from UnUˉnU_n - \bar U_n;

  5. The new data will be Zn=LUn{Z^*}_n=L{U^*}_n;

  6. Calculate the new variogram;

  7. Calculate and save the statistics of interest;

  8. Return to step 4 and repeat the process at least 1000 times.

Value

variogram_boot gives the variogram of each bootstrap.

variogram_or gives the original variogram.

pars_boot gives the estimatives of the nugget, sill, contribution, range and practical range for each bootstrap.

pars_or gives the original estimatives of the nugget, sill, contribution, range and practical range.

Invalid arguments will return an error message.

Author(s)

Diogo Francisco Rossoni [email protected]

Vinicius Basseto Felix [email protected]

References

Solow, A. R. (1985). Bootstrapping correlated data. Journal of the International Association for Mathematical Geology, 17(7), 769-775. https://doi.org/10.1007/BF01031616

Examples

# Example 1

## transforming the data.frame in an object of class geodata
data<- as.geodata(soilmoisture)

points(data) ## data visualization

var<- variog(data, max.dist = 140) ## Obtaining the variogram
plot(var)

## Fitting the model
mod<- variofit(var,ini.cov.pars = c(2,80),nugget = 2,cov.model = "sph")
lines(mod, col=2, lwd=2) ##fitted model

## Bootstrap procedure

boot<- gboot_solow(data,var,mod,B=10)
## For better Confidence interval, try B=1000

gboot_CI(boot,digits = 4) ## Bootstrap Confidence Interval

gboot_plot(boot) ## Bootstrap Variogram plot


# Example 2

## transforming the data.frame in an object of class geodata
data<- as.geodata(NVDI)

points(data) ## data visualization

var<- variog(data, max.dist = 18) ## Obtaining the variogram
plot(var)

## Fitting the model
mod<- variofit(var,ini.cov.pars = c(0.003,6),nugget = 0.003,cov.model = "gaus")
lines(mod, col=2, lwd=2) ##fitted model

## Bootstrap procedure

boot<- gboot_solow(data,var,mod,B=10)
## For better Confidence interval, try B=1000

gboot_CI(boot,digits = 4) ## Bootstrap Confidence Interval

gboot_plot(boot) ## Bootstrap Variogram plot

Variogram bootstrap

Description

Perform a boostrap based on error from the fitted model of the variogram.

Usage

gboot_variogram(data,var,model,B)

Arguments

data

object of the class geodata.

var

object of the class variogram.

model

object of the class variomodel.

B

number of the bootstrap that will be performed (default B=1000).

Details

The algorithm for the bootstrap variogram is the same presented for Davison and Hinkley (1997) for the non linear regression. We can write the variogram as γ^(h)=γmod(h)+ϵ\hat \gamma(h) = \gamma_{mod}(h)+\epsilon, where γmod(h)\gamma_{mod}(h) is the fitted model. The steps of the algorithm are:

  1. Set h=hh^*=h;

  2. Sample with replacement ϵ\epsilon^* from ϵϵˉ\epsilon - \bar \epsilon;

  3. The new variogram will be γ(h)=γmod(h)+ϵ\gamma^*(h^*) = \gamma_{mod}(h)+\epsilon^*;

  4. Calculate and save the statistics of interest;

  5. Return to step 2 and repeat the process at least 1000 times.

Value

variogram_boot gives the variogram of each bootstrap.

variogram_or gives the original variogram.

pars_boot gives the estimatives of the nugget, sill, contribution, range and practical range for each bootstrap.

pars_or gives the original estimatives of the nugget, sill, contribution, range and practical range.

Invalid arguments will return an error message.

Author(s)

Diogo Francisco Rossoni [email protected]

Vinicius Basseto Felix [email protected]

References

DAVISON, A.C.; HINKLEY, D. V. Bootstrap Methods and their Application. [s.l.] Cambridge University Press, 1997. p. 582

Examples

# Example 1

## transforming the data.frame in an object of class geodata
data<- as.geodata(soilmoisture)

points(data) ## data visualization

var<- variog(data, max.dist = 140) ## Obtaining the variogram
plot(var)

## Fitting the model
mod<- variofit(var,ini.cov.pars = c(2,80),nugget = 2,cov.model = "sph")
lines(mod, col=2, lwd=2) ##fitted model

## Bootstrap procedure

boot<- gboot_variogram(data,var,mod,B=10)
## For better Confidence interval, try B=1000

gboot_CI(boot,digits = 4) ## Bootstrap Confidence Interval

gboot_plot(boot) ## Bootstrap Variogram plot


# Example 2

## transforming the data.frame in an object of class geodata
data<- as.geodata(NVDI)

points(data) ## data visualization

var<- variog(data, max.dist = 18) ## Obtaining the variogram
plot(var)

## Fitting the model
mod<- variofit(var,ini.cov.pars = c(0.003,6),nugget = 0.003,cov.model = "gaus")
lines(mod, col=2, lwd=2) ##fitted model

## Bootstrap procedure

boot<- gboot_variogram(data,var,mod,B=10)
## For better Confidence interval, try B=1000

gboot_CI(boot,digits = 4) ## Bootstrap Confidence Interval

gboot_plot(boot) ## Bootstrap Variogram plot

Normalized Difference Vegetation Index experiment

Description

Field experiment, realized in CTI (Tecnical Center of Irrigation), in an area of 3 m x 24 m, with 88 observations in a regular grid.

Usage

data(soilmoisture)

Format

An object of class data.frame

Details

  • x a vector containing the sample locations(in cm) in the horizontal.

  • y a vector containing the sample locations(in cm) in the vertical.

  • z a vector containing the value of normalized difference vegetation index (NDVI).

References

HARA. A. T., GONÇALVES, A. C. A. Temporal stability of the spatial pattern of water storage in the soil at different spatial scales. (Doctoral thesis). Retrieved from url http://www.pga.uem.br/dissertacao-tese/710


Soil moisture experiment

Description

Field experiment, realized in CTI (Tecnical Center of Irrigation), in an area of 350 cm x 150 cm, with 355 observations in a regular grid.

Usage

data(soilmoisture)

Format

An object of class data.frame

Details

  • x a vector containing the sample locations(in cm) in the horizontal.

  • y a vector containing the sample locations(in cm) in the vertical.

  • z a vector containing the value of soil moisture in percents.

References

HARA. A. T., GONÇALVES, A. C. A. Temporal stability of the spatial pattern of water storage in the soil at different spatial scales. (Doctoral thesis). Retrieved from url http://www.pga.uem.br/dissertacao-tese/710