net.correlogram {stream.net} | R Documentation |
Compute the autocorrelation coefficients of an attribute for a sequence of separations in distance (lags) between stream segments.
net.correlogram (net, dist, segatt, nlags=10)
net |
A net.object . |
dist |
an upstream/downstream distance matrix from
net.dist , probably using ends=0.5 . |
segatt |
attribute associated with each segment.
If segatt is a character vector of length one,
then get attribute from net$segs$segatt , else
assume segatt is a numeric vector of length
equal to number of segments and in correct order. |
nlags |
number of lags in the output function. |
Uses total distances, ignoring upstream/downstream. The algorithm for autocorrelation coefficients, from the reference below, is
r(x) = sum(2 * z[i] * z[j])/sum(z[i]^2 + z[j]^2)
for all segment pairs i,j
at lag x
. Values
are in [-1, 1].
Lag distances are in method
units used in
net.dist
, and are in range [0, max(dist)]
.
A list with the following elements:
r | vector of autocorrelation coefficients at each lag |
lag | vector of lag distances |
num | vector of number of pairs at each lag |
Denis White, white.denis@epa.gov
Henley S. 1975. Autocorrelation coefficients from irregularly spaced areal data. Computers and Geosciences 2(4):437-438.
net.object
net.dist
net.autocorr.att
net.autocorr.onelag
# Q model random net net <- net.qmodel (5) net <- net.addsegs (net) dmat <- net.dist (net, ends=0.5, method="segment") # make rnorm and autocorrelated attributes att.rnorm <- net.addatt (net, dist="Normal", boundscaling=TRUE, vector=TRUE) att.autoc <- net.autocorr.att (net, dist=dmat, vector=TRUE, outscaling=TRUE) * 10 # plot correlograms cg1 <- net.correlogram (net, dist=dmat, segatt=att.rnorm) cg2 <- net.correlogram (net, dist=dmat, segatt=att.autoc) plot (cg1$lag, cg1$r, pch=19, type="b", ylim=c(-1,1), main="Random Normal") plot (cg2$lag, cg2$r, pch=19, type="b", ylim=c(-1,1), main="Autocorrelated")