Type: Package
Title: Tools to Improve the Use of Geostatistic
Version: 1.2.1
Author: Diogo Francisco Rossoni ORCID iD [aut, cre], Vinicius Basseto Felix [aut], Ricardo Puziol de Oliveira ORCID iD [ctb]
Maintainer: Diogo Francisco Rossoni <dfrossoni@uem.br>
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.
License: GPL-2 | GPL-3 [expanded from: GPL (≥ 2)]
Encoding: UTF-8
LazyData: true
Depends: R (≥ 2.10), geoR(≥ 1.9), tidyr, dplyr, ggplot2
RoxygenNote: 7.2.3
NeedsCompilation: no
Packaged: 2024-06-27 15:11:35 UTC; rpuzi
Repository: CRAN
Date/Publication: 2024-07-21 11:00:04 UTC

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

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


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 dfrossoni@uem.br

Vinicius Basseto Felix felix_prot@hotmail.com


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 probability\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 dfrossoni@uem.br

Vinicius Basseto Felix felix_prot@hotmail.com

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 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 dfrossoni@uem.br

Vinicius Basseto Felix felix_prot@hotmail.com

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 \epsilon({s_i})=Z({s_i})-\hat Z({s_i}), where \hat Z({s_i}) are obtained from cross-validation. The steps of the algorithm are:

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

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

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

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

  5. The new data will be 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 dfrossoni@uem.br

Vinicius Basseto Felix felix_prot@hotmail.com

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 dfrossoni@uem.br

Vinicius Basseto Felix felix_prot@hotmail.com


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 Z_n is an n vector of observations from a realization of a second-order stationary random process, Z(s_i), and the covariance matrix for Z_n is C. Suppose further that E(Z_n)={0_n}, where {0_n} is an n vector of zeroes. In practice Z_n can be centered by subtracting an estimate of the stationary mean from each observation. So, the steps of the algorithm are:

  1. Obtain C;

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

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

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

  5. The new data will be {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 dfrossoni@uem.br

Vinicius Basseto Felix felix_prot@hotmail.com

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 \hat \gamma(h) = \gamma_{mod}(h)+\epsilon, where \gamma_{mod}(h) is the fitted model. The steps of the algorithm are:

  1. Set h^*=h;

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

  3. The new variogram will be \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 dfrossoni@uem.br

Vinicius Basseto Felix felix_prot@hotmail.com

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


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

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