Learn R Programming

ncf (version 1.1-2)

Sncf: Nonparametric (cross-)correlation function for spatio-temporal data

Description

Sncf is the function to estimate the nonparametric (cross-)correlation function using a smoothing spline as an equivalent kernel. The function requires multiple observations at each location (use spline.correlog otherwise).

Usage

Sncf(x, y, z, w = NULL, df = NULL, type = "boot", resamp = 1000, 
npoints = 300, save = FALSE, filter = FALSE, fw = 0, max.it = 25, 
xmax = FALSE, na.rm = FALSE, latlon = FALSE, circ = FALSE, quiet = FALSE)

Arguments

x
vector of length n representing the x coordinates (or longitude; see latlon).
y
vector of length n representing the y coordinates (or latitude).
z
matrix of dimension n x p representing p observation at each location.
w
an optional second matrix of dimension n x p for species 2 (to estimate the spatial cross-correlation function).
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).
filter
if TRUE the Fourier filter method of Hall and coworkers is applied to ensure positive semidefiniteness of the estimator. (more work may be needed on this.)
fw
if filter is TRUE, it may be useful to truncate the function at some distance w sets the truncation distance. when set to zero no truncation is done.
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.
latlon
if TRUE, coordinates are latitude and longitude.
circ
if TRUE, the observations are assumed to be angular (in radians), and circular correlation is used.
quiet
if TRUE the counter is supressed during execution.

Value

  • An object of class "Sncf" is returned, consisting of the following components:
  • realThe list of estimates from the data.
  • $cbarthe regional average correlation.
  • $x.interceptthe lowest value at which the function is = 0. If correlation is initially negative, the distance is given as negative.
  • $e.interceptthe lowest value at which the function 1/e.
  • $y.interceptthe extrapolated value at x=0 (nugget).
  • $cbar.interceptdistance at which regional average correlation is reach.
  • $predicted$xthe x-axes for the fitted covariance function.
  • $predcited$ythe values for the covariance function.
  • bootA list with the analogous output from the bootstrap or null distribution.
  • $summarygives the full vector of output for the x.intercept, y.intercept, e.intercept, cbar.intercept, cbar and a quantile summary for the resampling distribution.
  • $bootif save=TRUE the full raw matrices from the resampling is saved.
  • max.distancethe maximum spatial distance considered.

Details

Missing values are allowed -- values are assumed missing at random. The circ argument computes a circular version of the Pearson's product moment correlation (see cor2). This option is to calculate the 'nonparametric phase coherence function' (Grenfell et al. 2001)

References

Hall, P. & Patil, P. (1994) Properties of nonparametric estimators of autocovariance for stationary random fields. Probability Theory and Related Fields, 99:399-424. Hall, P., Fisher, N.I. & Hoffmann, B. (1994) On the nonparametric estimation of covariance functions. Annals of Statistics, 22:2115-2134. Bjornstad, O.N. & Falck, W. (2001) Nonparametric spatial covariance functions: estimation and testing. Environmental and Ecological Statistics, 8:53-70. Bjornstad, O.N., Ims, R.A. & Lambin, X. (1999) Spatial population dynamics: Analysing patterns and processes of population synchrony. Trends in Ecology and Evolution, 11:427-431. Bjornstad, O. N., and J. Bascompte. (2001) Synchrony and second order spatial correlation in host-parasitoid systems. Journal of Animal Ecology 70:924-933. Grenfell, B.T., Bjornstad, O.N., & Kappey, J. (2001) Travelling waves and spatial hierarchies in measles epidemics. Nature 414:716-723.

See Also

summary.Sncf plot.Sncf Sncf2D Sncf.srf

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")
        )
#w data from a gaussian random field
    w <- cbind(
        rmvn.spa(x=x, y=y, p=2, method="gaus"),
        rmvn.spa(x=x, y=y, p=2, method="gaus")
        )
#multivariate nonparametric covariance function
    fit1 <- Sncf(x=x, y=y, z=z, resamp = 5)
    plot.Sncf(fit1)
    summary.Sncf(fit1)

#multivariate nonparametric cross-covariance function
    fit2 <- Sncf(x=x, y=y, z=z, w=w, resamp = 5)
    plot.Sncf(fit2)
    summary.Sncf(fit2)

Run the code above in your browser using DataLab