Learn R Programming

ncf (version 1.1-7)

Sncf2D: Anisotropic nonparametric (cross-)correlation function for spatio-temporal data

Description

Sncf2D is the function to estimate the anisotropic nonparametric correlation function in 8 (or arbitrary) directions (North - Southeast). Correlation functions are calculated for each different bearing. The function requires multiple observations at each location. (use spline.correlog.2D otherwise).

Usage

Sncf2D(x, y, z, w = NULL, df = NULL, type = "boot", resamp = 1000, npoints = 300, save = FALSE, max.it = 25, xmax = FALSE, na.rm = FALSE, jitter = FALSE, quiet = FALSE, angle = c(0, 22.5, 45, 67.5, 90, 112.5, 135, 157.5))

Arguments

x
vector of length n representing the x coordinates.
y
vector of length n representing the y coordinates.
z
matrix of dimension n x p representing p observation at each location.
w
an optional second matrix of dimension n x p for variable 2 (to estimate spatial or lagged cross-correlation functions).
df
degrees of freedom for the spline. Default is sqrt(n).
type
takes the value "boot" (default) to generate a bootstrap distribution or "perm" to generate a null distribution for the estimator
resamp
the number of resamples for the bootstrap or the null distribution.
npoints
the number of points at which to save the value for the spline function (and confidence envelope / null distribution).
save
if TRUE the whole matrix of output from the resampling is saved (an resamp x npoints dimensional matrix).
max.it
the maximum iteration for the Newton method used to estimate the intercepts.
xmax
if FALSE the max observed in the data is used. Otherwise all distances greater than xmax is omitted.
na.rm
if TRUE, NA's will be dealt with through pairwise deletion of missing values for each pair of time series -- it will dump if any one pair has less than two (temporally) overlapping observations.
jitter
if TRUE, jitters the distance matrix, to avoid problems associated with fitting the function to data on regular grids
quiet
if TRUE the counter is supressed during execution.
angle
specifies number of cardinal directions and angles for which to calculate correlation functions. Default are 8 directions between 0 and 180.

Value

An object of class "Sncf2D" is returned, consisting of a list of estimates for each cardinal direction :
real
The list of estimates from the data.
$cbar
the regional average correlation.
$x.intercept
the lowest value at which the function is = 0. If correlation is initially negative, the distance is given as negative.
$e.intercept
the lowest value at which the function 1/e.
$y.intercept
the extrapolated value at x=0 (nugget).
$cbar.intercept
distance at which regional average correlation is reach.
$predicted$x
the x-axes for the fitted covariance function.
$predcited$y
the values for the covariance function.
boot
A list with the analogous output from the bootstrap or null distribution.
$summary
gives the full vector of output for the x.intercept, y.intercept, e.intercept, cbar.intercept, and the cbar and a quantile summary for the resampling distribution.
$boot
if save=TRUE the full raw matrices from the resampling is saved.
angle
A vector with the cardinal directions.
max.distance
the maximum spatial distance.

Details

Correlation functions are calculated on projected distances onto the different bearings so ALL data are used for each direction. The (obsolete?) oldncf2D used the alternative of slizing up the data like pieces of a pie. Latitude-longitude coordinates can NOT be used. Missing values are allowed - values are assumed missing at random.

I have implemented an optional argument: jitter if TRUE this jitters the distance matrix, to avoid some problems I've had with spline-smoothing data from regular grid-data.

References

Bjornstad, O. N., M. Peltonen, A. M. Liebhold, and W. Baltensweiler. 2002. Waves of larch budmoth outbreaks in the European Alps. Science 298:1020-1023.

See Also

summary.Sncf2D plot.Sncf2D cc.offset Sncf spline.correlog.2D

Examples

Run this code
#first generate some sample data
    x <- expand.grid(1:20, 1:5)[,1]
    y <- expand.grid(1:20, 1:5)[,2]
#z data from an exponential random field
    z <- cbind(
        rmvn.spa(x=x, y=y, p=2, method="exp"),
        rmvn.spa(x=x, y=y, p=2, method="exp")
        )
#anisotorpic nonparametric covariance function at 30 and 60 degrees
    fit1 <- Sncf2D(x=x, y=y, z=z, resamp = 0, angle=c(30, 60))
    ## Not run: plot.Sncf2D(fit1)
    summary.Sncf2D(fit1)
    
    #What distance is the peak in correlation
    cc.offset(fit1)

Run the code above in your browser using DataLab