Learn R Programming

dplR (version 1.8.0)

corr.series.seg: Compute Correlation between a Series and a Master Chronology

Description

Compute correlation between a tree-ring series and a master chronology by segment.

Usage

corr.series.seg(rwl, series, series.yrs = as.numeric(names(series)),
                seg.length = 50, bin.floor = 100, n = NULL,
                nyrs = NULL, prewhiten = TRUE, ar.order.max = NULL,
                biweight = TRUE,
                method = c("spearman", "pearson","kendall"),
                pcrit = 0.05,
                make.plot = TRUE, floor.plus1 = FALSE, ...)

Value

A list containing matrices bins,

moving.rho, and vectors spearman.rho,

p.val, and overall.

Matrix bins contains the years encapsulated by each bin (segments). Matrix moving.rho contains the moving correlation and p-value for a moving average equal to

seg.length. Vector spearman.rho contains the correlations by bin and p.val contains the p-values. Vector overall contains the average correlation and p-value.

Arguments

rwl

a data.frame with series as columns and years as rows such as that produced by read.rwl.

series

a numeric or character vector. Usually a tree-ring series. If the length of the value is 1, the corresponding column of rwl is selected (by name or position) as the series and ignored when building the master chronology. Otherwise, the value must be numeric.

series.yrs

a numeric vector giving the years of series. Defaults to as.numeric(names(series)). Ignored if series is an index to a column of rwl.

seg.length

an even integral value giving length of segments in years (e.g., 20, 50, 100 years).

bin.floor

a non-negative integral value giving the base for locating the first segment (e.g., 1600, 1700, 1800 AD). Typically 0, 10, 50, 100, etc.

n

NULL or an integral value giving the filter length for the hanning filter used for removal of low frequency variation.

nyrs

NULL or a number greater than zero. If not NULL, each series is divided by a smoothing spline with this rigidity (see caps) to remove low-frequency variation, as detrend does with method = "Spline". A value of 1 or less is taken as a proportion of each series' length. Unlike the hanning filter, the spline removes no years from the ends of a series. Cannot be combined with n.

prewhiten

logical flag. If TRUE each series is whitened using ar.

ar.order.max

NULL or a positive integer giving the maximum order of the ar model used to prewhiten. Prewhitening removes as many years from the start of each series as the order of the model. If NULL, the order is chosen by AIC up to the ar default, which on long series can be 20 or more. Requires prewhiten = TRUE.

biweight

logical flag. If TRUE then a robust mean is calculated using tbrm.

method

Can be either "pearson", "kendall", or "spearman" which indicates the correlation coefficient to be used. Defaults to "spearman". See cor.test.

pcrit

a number between 0 and 1 giving the critical value for the correlation test.

make.plot

logical flag indicating whether to make a plot.

floor.plus1

logical flag. If TRUE, one year is added to the base location of the first segment (e.g., 1601, 1701, 1801 AD).

...

other arguments passed to plot.

Author

Andy Bunn. Patched and improved by Mikko Korpela.

Details

This function calculates the correlation between a tree-ring series and a master chronology built from a rwl object. Correlations are done by segment (see below) and with a moving correlation with length equal to the seg.length. The function is typically invoked to produce a plot.

See Also

corr.series.seg, skel.plot, series.rwl.plot, ccf.series.rwl

Examples

Run this code
library(utils)
data(co021)
dat <- co021
## Create a missing ring: delete the 1500 ring of series 641143 and
## drop the original from the master.  Dated from the bark, every ring
## before 1500 now sits one year late.
flagged <- dat$"641143"
names(flagged) <- rownames(dat)
flagged <- delete.ring(flagged, year = 1500)
dat$"641143" <- NULL
seg.100 <- corr.series.seg(rwl = dat, series = flagged,
                           seg.length = 100, biweight = FALSE)
if (FALSE) {
flagged2 <- co021$"641143"
names(flagged2) <- rownames(dat)
seg.100.1 <- corr.series.seg(rwl=dat, seg.length=100, biweight=FALSE,
                             series = flagged2)
## Select series by name or column position
seg.100.2 <- corr.series.seg(rwl=co021, seg.length=100, biweight=FALSE,
                             series = "641143")
seg.100.3 <- corr.series.seg(rwl=co021, seg.length=100, biweight=FALSE,
                             series = which(colnames(co021) == "641143"))
identical(seg.100.1, seg.100.2) # TRUE
identical(seg.100.2, seg.100.3) # TRUE
}

Run the code above in your browser using DataLab