Learn R Programming

prevR (version 2.2)

krige,prevR-method: Spatial interpolation (kriging and inverse distance weighting) for objects of class prevR.

Description

These functions execute a spatial interpolation of a variable of the slot rings of an object of class prevR. The method krige implements the ordinary kriging technique. The method idw executes an inverse distance weighting interpolation.

Usage

## S3 method for class 'ANY,prevR':
krige(formula, locations,
      N = NULL, R = NULL, model = NULL,
      nb.cells = 100, cell.size = NULL,
      fit = "auto", keep.variance = FALSE, show.variogram = FALSE,
      \dots
     )
## S3 method for class 'ANY,prevR':
idw(formula, locations,
    N = NULL, R = NULL,
    nb.cells = 100, cell.size = NULL, 
    idp = 2,
    \dots
   )

Arguments

formula
variable(s) to interpolate (see details).
locations
object of class prevR.
N
integer or list of integers corresponding to the rings to use.
R
integer or list of integers corresponding to the rings to use.
model
a variogram model returned by the function vgm{gstat}.
nb.cells
number of cells on the longuest side of the studied area (unused if cell.size is defined).
cell.size
size of each cell (in the unit of the projection).
fit
"auto" for using a variogram automatically fitted from the data, "manual" for using a variogram fitted through a graphic interface (unused if model is defined).
keep.variance
return variance of estimates?
show.variogram
plot the variogram?
idp
inverse distance weighting power (see idw{gstat}).
...
additional arguments transmited to krige{gstat} or idw{gstat}.

Value

  • Object of class SpatialPixelsDataFrame. The name of estimated surfaces depends on the name of the interpolated variable, N and R (for example: r.radius.N300.RInf). If you ask the function to return variance (keep.variance=TRUE), corresponding surfaces names will have the suffix .var. NA value is applied to points located outside of the studied area (voir NA.outside.SpatialPolygons).

encoding

utf8

Details

formula specifies the variable(s) to interpolate. Only variables available in the slot rings of locations could be used. Possible values are "r.pos", "r.n", "r.prev", "r.radius", "r.clusters", "r.wpos", "r.wn" ou "r.wprev". Variables could be specifed with a character string or a formula (example: list(r.pos~1,r.prev~1). Only formula like variable.name~1 are accepted. For more complexe interpolations, use directly functions krige and idw from gstat. N and R determine the rings to use for the interpolation. If they are not defined, surfaces will be estimated for each available couples (N,R). Several interpolations could be simultaneously calculated if several variables and/or several values of N and R are defined. In the case of an ordinary kriging, the method krige from prevR will try to fit automatically a exponantial variogram to the sample variogram (fit="auto"). If you choose fit="manual", the sample variogram will be plotted and a graphical dialog box (adapted from eyefit{geoR}) will appear for a manual and visual fitting. You can also specify directly the variogram to use with the parameter model. Interpolations are calculated on spatial gridd obtained with as.SpatialGrid.

References

Larmarange Joseph, Vallo Roselyne, Yaro Seydou, Msellati Philippe and Meda Nicolas (2011) "Methods for mapping regional trends of HIV prevalence from Demographic and Health Surveys (DHS)", Cybergeo : European Journal of Geography, no 558, http://cybergeo.revues.org/24606, DOI: 10.4000/cybergeo.24606.

See Also

krige{gstat}, idw{gstat}, rings,prevR-method.

Examples

Run this code
dhs <- rings(fdhs, N=c(100,200,300,400,500))
radius.N300 <- krige('r.radius', dhs, N=300, nb.cells=200)
spplot(radius.N300,
       cuts=100, col.regions=prevR.colors.blue(101), 
       main="Radius of circle (N=300)"
      )


prev.krige <- krige('r.wprev', dhs, N=c(100,300,500),R=Inf,
                    fit="manual",keep.variance=TRUE
                   )
str(prev.krige)
spplot(prev.krige,
       c('r.wprev.N100.RInf','r.wprev.N300.RInf','r.wprev.N500.RInf'),
       cuts=100, col.regions=prevR.colors.red(101)
      )

Run the code above in your browser using DataLab