Learn R Programming

dplR (version 1.6.8)

detrend.series: Detrend a Ring-Width Series

Description

Detrend a tree-ring series by one of two methods, a smoothing spline or a statistical model. The series and fits are plotted by default.

Usage

detrend.series(y, y.name = "", make.plot = TRUE,
               method = c("Spline", "ModNegExp", "Mean", "Ar", "Friedman"),
               nyrs = NULL, f = 0.5, pos.slope = FALSE,
               constrain.modnegexp = c("never", "when.fail", "always"),
               verbose = FALSE, return.info = FALSE,
               wt, span = "cv", bass = 0)

Arguments

y

a numeric vector. Usually a tree-ring series.

y.name

an optional character vector to name the series for plotting purposes.

make.plot

a logical flag. Makes plots of the raw data and detrended data if TRUE.

method

a character vector to determine the detrending methods. See details below. Possible values are all subsets of c("Spline", "ModNegExp", "Mean", "Ar", "Friedman"). Defa ults to using all the available methods.

nyrs

a number controlling the smoothness of the fitted curve in method "Spline", defaults to 0.67 of series length if nyrs is NULL. See ffcsaps.

f

a number between 0 and 1 giving the frequency response or wavelength cutoff in method "Spline". Defaults to 0.5. See ffcsaps.

pos.slope

a logical flag. Will allow for a positive slope to be used in method "ModNegExp". If FALSE the line will be horizontal.

constrain.modnegexp

a character string which controls the constraints of the "ModNegExp" model. The value is an answer to the question: When should the parameters of the modified negative exponential function be constrained? The options are "never": do not constrain (the default), "when.fail": only compute the constrained solution if the unconstrained fit contains other than positive values, and "always": return the constrained solution, even if the unconstrained one would have been valid. See ‘Details’.

verbose

a logical flag. Write out details?

return.info

a logical flag. If TRUE, details about models and data will be added to the return value. See ‘Value’.

wt

a numeric vector of case weights for method "Friedman". The default means equals weights.

span

a numeric value controlling method "Friedman", or "cv" (default) for automatic choice by cross-validation. See supsmu.

bass

a numeric value controlling the smoothness of the fitted curve in method "Friedman". See supsmu.

Value

If several methods are used, returns a data.frame containing the detrended series (y) according to the methods used. The columns are named and ordered to match method. If only one method is selected, returns a vector.

If return.info is TRUE, the return value is a list with three parts:

series

the main result described above (data.frame or vector)

model.info

Information about the models corresponding to each output series. Whereas series may return a vector, model.info is always a list where each top level element corresponds to one selected method. Also these elements are named and arranged according to the methods selected. Each element is a list with some of the following sub-elements, depending on which detrending method was actually used:

n.zeros

See "data.info" below. Always present.

zero.years

See "data.info". Always present.

method

The method actually used for detrending. One of "Mean", "Line", "ModNegExp", "Spline" or "Ar". Always present.

mean

Mean of the input series, missing values removed. Only for method "Mean".

coefs

Coefficients of the model. Methods "Line" and "ModNegExp".

formula

The "ModNegExp" formula.

is.constrained

A logical flag indicating whether the parameters of the "ModNegExp" model were constrained. Only interesting when argument constrain.modnegexp is set to "when.fail".

nyrs

The value of nyrs used for ffcsaps. Only for method "Spline".

order

The order of the autoregressive model, selected by AIC (Akaike information criterion). Only for method "Ar".

ar

The autoregressive coefficients used by method "Ar". A numeric vector ordered by increasing lag.

data.info

Information about the input series: number ("n.zeros") and location ("zero.years") of zero values. If the locations are in a character vector, they are years. Otherwise they are indices to the input series.

Details

This detrends and standardizes a tree-ring series. The detrending is the estimation and removal of the tree<U+2019>s natural biological growth trend. The standardization is done by dividing each series by the growth trend to produce units in the dimensionless ring-width index (RWI). There are currently three methods available for detrending although more are certainly possible. The methods implemented are a smoothing spline via ffcsaps (method = "Spline"), a modified negative exponential curve (method = "ModNegExp"), or a simple horizontal line (method = "Mean").

The "Spline" approach uses an spline where the frequency response is 0.50 at a wavelength of 0.67 * “series length in years”, unless specified differently using nyrs and f in the function ffcsaps. This attempts to remove the low frequency variability that is due to biological or stand effects.

The "ModNegExp" approach attempts to fit a classic nonlinear model of biological growth of the form \(f(t) = a e^{b t} + k\), where the argument of the function is time, using nls. See Fritts (2001) for details about the parameters. Option constrain.modnegexp gives a possibility to constrain the parameters of the modified negative exponential function. If the constraints are enabled, the nonlinear optimization algorithm is instructed to keep the parameters in the following ranges: \(a \ge 0\), \(b \le 0\) and \(k \ge 0\). The default is to not constrain the parameters (constrain.modnegexp = "never") for nls but warn the user when the parameters go out of range.

If a suitable nonlinear model cannot be fit (function is non-decreasing or some values are not positive) then a linear model is fit. That linear model can have a positive slope unless pos.slope is FALSE in which case method "Mean" is used.

The "Mean" approach fits a horizontal line using the mean of the series. This method is the fallback solution in cases where the "Spline" or the linear fit (also a fallback solution itself) contains zeros or negative values, which would lead to invalid ring-width indices.

The "Ar" approach is also known as prewhitening where the detrended series is the residuals of an ar model divided by the mean of those residuals to yield a series with white noise and a mean of one. This method removes all but the high frequency variation in the series and should only be used as such.

These methods are chosen because they are commonly used in dendrochronology. There is a rich literature on detrending and many researchers are particularly skeptical of the use of the classic nonlinear model of biological growth (\(f(t) = a e^{b t} + k\)) for detrending. It is, of course, up to the user to determine the best detrending method for their data.

See the references below for further details on detrending.

The "Friedman" approach uses Friedman<U+2019>s ‘super smoother’ as implemented in supsmu. The parameters wt, span and bass can be adjusted, but periodic is always set to FALSE.

References

Cook, E. R. and Kairiukstis, L. A., editors (1990) Methods of Dendrochronology: Applications in the Environmental Sciences. Springer. ISBN-13: 978-0-7923-0586-6.

Fritts, H. C. (2001) Tree Rings and Climate. Blackburn. ISBN-13: 978-1-930665-39-2.

See Also

detrend

Examples

Run this code
# NOT RUN {
library(stats)
library(utils)
## Using a plausible representation of a tree-ring series
gt <- 0.5 * exp (-0.05 * 1:200) + 0.2
noise <- c(arima.sim(model = list(ar = 0.7), n = 200, sd = 0.5))+2
series <- gt * noise
series.rwi <- detrend.series(y = series, y.name = "Foo", verbose=TRUE)
## Use series CAM011 from the Campito data set
data(ca533)
series <- ca533[, "CAM011"]
names(series) <- rownames(ca533)
# defaults to all five methods
series.rwi <- detrend.series(y = series, y.name = "CAM011", verbose=TRUE)
# see plot with three methods
series.rwi <- detrend.series(y = series, y.name = "CAM011",
                             method=c("Spline", "ModNegExp","Friedman"))
# see plot with two methods
# interesting to note difference from ~200 to 250 years 
# in terms of what happens to low frequency growth
series.rwi <- detrend.series(y = series, y.name = "CAM011",
                             method=c("Spline", "ModNegExp"))
# see plot with just one method and change the spline
# stiffness to 50 years (which is not neccesarily a good choice!)
series.rwi <- detrend.series(y = series, y.name = "CAM011",
                             method="Spline",nyrs=50)
# note that method "Ar" doesn't get plotted in first panel
# since this approach doesn't approximate a growth curve.
series.rwi <- detrend.series(y = series, y.name = "CAM011",
                             method="Ar")
# }

Run the code above in your browser using DataLab