Learn R Programming

dplR (version 1.4.9)

rwi.stats.running: Calculates Running Window Statistics on Detrended Ring Width Series

Description

This function calculates descriptive statistics on a data.frame of (usually) ring-width indices. The statistics are computed in a running window with adjustable length and overlap.

Usage

rwi.stats.running(rwi, ids=NULL, period=c("max", "common"),
                  running.window=TRUE,
                  window.length=min(50,nrow(rwi)),
                  window.overlap=floor(window.length/2),
                  first.start=NULL,
                  min.corr.overlap=min(30,window.length),
                  round.decimals=3,
                  zero.is.missing=FALSE)

Arguments

rwi
a data.frame with detrended and standardised ring width indices as columns and years as rows such as that produced by detrend.
ids
an optional data.frame with column one named tree giving a numeric id for each tree and column two named core giving a numeric id for each core. Defaults to one core per tree as data
period
a character string, either common or max indicating whether correlations should be limited to complete observations over the period common to all cores (i.e. rows common to all samples) or the maximum pairw
running.window
logical flag indicating whether to use a running window (TRUE, the default) or to ignore the other window parameters and effectively use one window covering all years (FALSE).
window.length
numeric value indicating the length of the running window in years. The default is 50 years or the number of years (rows) in rwi, whichever is smaller.
window.overlap
numeric value indicating the overlap of consecutive window positions, i.e. the number of common years. The default is half of the window length, rounded down.
first.start
an optional numeric value setting the position of the first window. Must be a value between 1 and n.years-window.length+1, where n.years is the number of years in rwi. The default value
min.corr.overlap
numeric value setting the minimum number of common years in any pair of ring width series required for their correlation to be included in the calculations. Smaller overlaps are considered to yield unreliable correlation values which are
round.decimals
the desired number of decimal places in the results.
zero.is.missing
logical flag indicating whether to treat zeros as missing values (TRUE) or to include them in computation (FALSE, the default).

Value

  • A data.frame containing the following columns (each row corresponds to one position of the window): start.year the first year in the window (not present if running.window is FALSE), mid.year the middle year in the window, rounded down (not present if running.window is FALSE), end.year the last year in the window (not present if running.window is FALSE), n.tot total number of correlations computed, n.wt number of within-tree correlations computed, n.bt number of between-tree correlations computed, rbar.tot the mean of all correlation between different cores, rbar.wt the mean of the correlations between series from the same tree over all trees, rbar.bt the mean interseries correlation between all series from different trees, c.eff the effective number of cores (takes into account the number of within-tree correlations in each tree), rbar.eff the effective signal calculated as rbar.bt / (rbar.wt + (1-rbar.wt) / c.eff), eps the expressed population signal, n the average number of trees (for each year, a tree needs at least one non-NA core in order to be counted).

Details

This calculates a variety of descriptive statistics commonly used in dendrochronology. For correctly calculating the statistics on within and between series variability, an appropriate mask (parameter ids) must be provided that identifies each series with a tree as it is common for dendrochronologists to take more than one core per tree. The function read.ids is be helpful for creating a mask based on the series id. If ids has duplicate tree/core combinations, the corresponding series are averaged before any statistics are computed. Note that period=common can produce NaN for many of the stats if there is no common overlap period among the cores. This happens especially in chronologies with floating subfossil samples (e.g., ca533). Some of the statistics are specific to dendrochronology (e.g., the effective number of cores or the expressed population signal). Users unfamiliar with these should see Cook and Kairiukstis (1990) and Fritts (2001) for further details. The default value of zero.is.missing is FALSE mostly because of backward compatibility of results. Usually it will probably make more sense to set this to TRUE. If the parameter is left to the default value, the user will be warned in case zeros are present.

References

Cook, E.R. and Kairiukstis, L.A. (1990) Methods of Dendrochronology: Applications in the Environmental Sciences. Springer. ISBN-13: 978-0792305866. Fritts, H.C. (2001) Tree Rings and Climate. Blackburn. ISBN-13: 978-1930665392.

See Also

detrend, cor, read.ids, rwi.stats

Examples

Run this code
data(ca533)
ca533.rwi <- detrend(rwl = ca533, method = "Mean") # mean is fast
ca533.ids <- read.ids(ca533, stc=c(3, 2, 3))
rwi.stats.running(ca533.rwi, ca533.ids)

## Plot the chronology showing a potential cutoff year based on eps
ca533.rwi <- detrend(rwl = ca533, method = "Spline") # detrend again
ca533.crn <- chron(ca533.rwi)
## Running stats on the rwi with an 80 yr window
foo <- rwi.stats.running(ca533.rwi, ca533.ids, window.length=80)
yrs <- as.numeric(rownames(ca533.crn))
bar <- data.frame(yrs=c(min(yrs), foo$mid.year, max(yrs)),
                  eps=c(NA, foo$eps, NA))
par(mar = c(3, 3, 3, 3), mgp = c(1.25, 0.25, 0), tcl = 0.25,
    mfcol=c(2, 1))
plot(yrs, ca533.crn[, 1], type="n", xlab = "Years", ylab = "RWI")
xx <- c(500, 500, max(bar$yrs[bar$eps < 0.8], na.rm=TRUE),
        max(bar$yrs[bar$eps < 0.8], na.rm=TRUE))
yy <- c(-1, 3, 3, -1)
polygon(xx, yy, col="grey80")
abline(h=1, lwd=1.5)
lines(yrs, ca533.crn[, 1], col="grey50")
lines(yrs, ffcsaps(ca533.crn[, 1], nyrs=32), col="red", lwd=2)
par(new = TRUE)

## Second plot is the chronology after the cut off only
plot(bar$yrs, bar$eps, type="b", xlab = "", ylab = "", axes = FALSE,
     pch=20, col="blue")
axis(4, at = pretty(foo$eps))
mtext("EPS", side = 4, line = 1.25)
box()
yr.mask <- yrs > max(bar$yrs[bar$eps<0.8], na.rm=TRUE)
plot(yrs[yr.mask], ca533.crn[yr.mask, 1], type="n",
     xlab = "Years", ylab = "RWI")
abline(h=1, lwd=1.5)
lines(yrs[yr.mask], ca533.crn[yr.mask, 1], col="grey50")
lines(yrs[yr.mask], ffcsaps(ca533.crn[yr.mask, 1], nyrs=32),
      col="red", lwd=2)

Run the code above in your browser using DataLab