Learn R Programming

FeedbackTS (version 1.4)

krige: Kriging function

Description

Variogram analysis and kriging prediction used to analyze feedback and change-in-feedback across space.

Usage

krige(coordinates, statistic, variog.param, grid, krige.param, plots = TRUE)

Arguments

coordinates

a 2-column matrix with latitudes and longitudes of observation sites.

statistic

a numeric vector specifying the values, at observation sites, of the statistic to be predicted.

variog.param

a list of arguments used to fit the semivariogram to data, some of these arguments being input of the function variofit in the geoR package:

keep.distance:

a numeric value between zero and one allowing to specify the maximum distance when fitting the variogram. This maximum distance is the product between the proportion keep.distance and the maximum distance between observation sites.

nb.bin:

a numeric value specifying the number of bins to be used when fitting the semivariogram.

cov.pars:

a numeric vector with initial values for the exponential covariance parameters, namely the partial sill and the range parameter.

nugget:

a numeric value for the nugget parameter. Regarded as a fixed value if fix.nugget = TRUE or as an initial value for the minimization algorithm if fix.nugget = FALSE.

fix.nugget:

logical, indicating whether the nugget parameter should be regarded as fixed (fix.nugget = TRUE) or should be estimated (fix.nugget = FALSE).

coordinates.scaling:

a numeric value by which the matrix coordinates is multipled when fitting the semivariogram. If coordinates.scaling = 1, raw coordinates are used.

statistic.scaling:

a numeric value by which the statistic to be predicted is multipled when fitting the semivariogram. If statistic.scaling = 1, the raw statistic is used.

grid

a list of arguments defining the grid over which the statistic is predicted:

x:

a numeric vector of longitudes.

y:

a numeric vector of latitudes.

border:

a character string that names the region in the world within which the statistic will be predicted. This is a character string in the database world; see the function map in the maps package.

proj:

a projection definition; see the function project in the proj4 package.

degrees:

a logical indicating if the lat/long coordinates are assumed to be in degrees (if degrees = TRUE), or in radians (if degrees = FALSE).

krige.param

a list of arguments specifying the type of kriging to be performed and that are used as arguments of the function krige.control in the geoR package:

type.krige:

a character string specifying the type of kriging to be performed. Options are "SK" and "OK" corresponding to simple or ordinary kriging. Kriging with external trend and universal kriging can be defined setting type.krige = "OK" and specifying the trend model using the arguments trend.d.

trend.d:

a character string specifying the trend (covariate) values at the data locations.

plots

a logical indicating if plots characterizing the variogram analysis and the kriging prediction are produced (if plots = TRUE) or not (if plots = FALSE), default is TRUE.

Value

a list of items characterizing the variogram analysis and the kriging prediction:

input

the list of arguments in the call of the krige function except the argument plots.

MAP

a list allowing to draw the border of the study region that can be made of several polygons. This is the output of the function map in the maps package.

grid

a 2-column matrix providing the coordinates (in degrees) of the nodes of the prediction locations.

in.region

a logical vector indicating, for each grid node whose coordinates are given in the 2-column matrix grid, if the node is in the study region or not. The study region is defined by MAP.

variofit.wls

a list providing the result of the weighted-least-square estimation of the semivariogram parameters. This is the output of the function variofit in the geoR package.

krige

a list providing the result of the spatial prediction for fixed covariance parameters given by variofit.wls. This is the output of the function krige.conv in the geoR package.

Details

If plots = TRUE, six plots are produced. Plot 1: Estimation of the semivariogram of the statistic using the weighted least squares method (dots: sample semivariogram; curve: theoretical semivariogram -- exponential covariance function with nugget effect). Plot 2: Assessment of the existence of a spatial structure based on a Monte-Carlo test. Plot 3: Assessment of the confidence envelopes of the semivariogram. Plot 4: Boxplots of kriging prediction (left) and kriging standard error (right). Plot 5: Kriging prediction. Plot 6: Kriging standard error.

References

Soubeyrand, S., Morris, C. E. and Bigg, E. K. (2014). Analysis of fragmented time directionality in time series to elucidate feedbacks in climate data. Environmental Modelling and Software 61: 78-86.

See Also

rain.feedback.stats, map in the maps package, variofit.wls and krige.conv in the geoR package

Examples

Run this code
# NOT RUN {
#### load data of feedback and change-in-feedback indices in 88 sites across Australia
data(rain.feedback.stats)

#### spatial coordinates of the 88 sites
coord=rain.feedback.stats[,3:4]

#### feedback index
stat1=rain.feedback.stats[["Feedback.whole.period"]]

#### variogram analysis and kriging of feedback index
## computer intensive stage
# }
# NOT RUN {
par(mfrow=c(2,3), mar=c(5.1,4.1,4.1,4.1))
kr1=krige(coordinates=coord, statistic=stat1,
   grid=list(x=seq(110,155,0.25),y=seq(-45,-11,0.25),border="Australia", 
      proj="+proj=lcc +lat_1=-18 +lat_2=-36 +lat0=-25 +lon_0=140",degrees=TRUE),
   variog.param=list(keep.distance=2/3,nb.bin=15,cov.pars=c(0.0008,10^6),
      nugget=0.0001,fix.nugget=FALSE,coordinates.scaling=10^5,statistic.scaling=0.01),
   krige.param=list(type.krige="ok",trend.d="1st"),plots=TRUE) 
# }

Run the code above in your browser using DataLab