Professional Documents
Culture Documents
A Dendrochronology Program Library in R (DPLR) : Andrew G. Bunn
A Dendrochronology Program Library in R (DPLR) : Andrew G. Bunn
A Dendrochronology Program Library in R (DPLR) : Andrew G. Bunn
TECHNICAL NOTE
A dendrochronology program library in R (dplR)
Andrew G. Bunn
Environmental Sciences, Huxley College, Western Washington University, Bellingham, WA 98225-9181, USA
Abstract
I present and describe a new software package in the R statistical programming environment for dendrochronology.
R is considered the world’s pre-eminent open-source statistical computing environment where users can contribute
packages, which are freely available on the Internet. The dendrochronology program library in R (dplR) is able to read
standard decadal-format files and allows users to perform several standard analyses including interactive detrending,
chronology building, and the calculation of standard descriptive statistics. The package can also produce a variety of
publication quality plots. The dplR package should make it easier for dendrochronologists to take advantage of R and
use it as their primary analytic environment.
r 2008 Elsevier GmbH. All rights reserved.
1125-7865/$ - see front matter r 2008 Elsevier GmbH. All rights reserved.
doi:10.1016/j.dendro.2008.01.002
ARTICLE IN PRESS
116 A.G. Bunn / Dendrochronologia 26 (2008) 115–124
Table 1. Individual series statistics produced by dplR function rwl.stats for the Hurricane Ridge ring-width data
Series First year Last year Span Mean Median Standard Skewness Mean First-order
deviation sensitivity autocorrelation
712011 1811 1983 173 0.571 0.490 0.302 1.277 0.324 0.724
712012 1770 1983 214 0.567 0.520 0.257 0.659 0.271 0.728
712021 1824 1983 160 1.427 1.375 0.372 0.253 0.224 0.395
712022 1838 1983 146 1.565 1.465 0.458 1.438 0.206 0.481
712031 1764 1983 220 0.888 0.865 0.248 0.295 0.201 0.589
712032 1828 1983 156 1.140 1.120 0.290 0.496 0.194 0.535
712041 1722 1983 262 0.802 0.760 0.255 0.576 0.207 0.654
712042 1773 1983 211 0.564 0.560 0.196 0.378 0.207 0.725
712051 1761 1983 223 0.714 0.600 0.400 0.805 0.245 0.827
712052 1772 1931 160 0.755 0.600 0.476 1.641 0.227 0.832
712061 1797 1983 187 0.921 0.850 0.302 1.127 0.182 0.749
712062 1777 1983 207 0.920 0.890 0.353 0.451 0.178 0.787
712071 1883 1983 101 1.959 1.900 0.592 0.497 0.205 0.567
712072 1889 1983 95 2.185 2.210 0.552 0.167 0.201 0.525
712081 1861 1983 123 1.083 1.090 0.421 0.249 0.224 0.769
712082 1864 1983 120 1.845 1.860 1.031 0.211 0.195 0.910
712091 1810 1983 174 1.091 0.970 0.429 1.989 0.188 0.755
712092 1715 1983 269 0.863 0.760 0.467 0.954 0.234 0.841
712101 1702 1983 282 1.049 0.980 0.426 0.724 0.238 0.724
712102 1706 1983 278 0.871 0.770 0.418 1.392 0.221 0.764
712111 1748 1983 236 0.571 0.510 0.283 1.404 0.258 0.791
712121 1730 1983 254 0.788 0.655 0.538 1.380 0.214 0.895
712122 1698 1983 286 0.726 0.640 0.385 1.619 0.217 0.848
locally onto the computer, but R also allows files to be smoothing spline approach closely follows the ‘‘n-year
read remotely over the Internet. spline’’ approach first described by Cook and Peters
The dplR package also produces some common (1981) where Gt is calculated as a spline with a frequency
descriptive statistics with the rwl.stats function. response of 50% at a wavelength of n years. Here, n is
For example, using the raw ring-width data from fixed as 2/3 the length of the series (Cook et al., 1990).
Hurricane Ridge: The last approach is to fit Gt as the mean of the series.
In all three cases, the RWI is calculated by division:
4wa082.stats o- rwl.stats(wa082)
RWIt ¼ Rt/Gt, where the actual growth (R) is divided
The object wa082.stats contains various statistics by the expected growth (G) at time t. The user can
on individual series such as the mean, median, and also detrend interactively and choose a different
standard deviation of the ring widths for each series in detrending method for each series using the i.
addition to the mean sensitivity (Fritts, 2001) and first- detrend function:
order autocorrelation (Table 1).
4wa082.rwi o- i.detrend(wa082)
The raw ring-width data can be detrended interac-
tively, one series at a time, or all at once with the user This produces a plot showing each series and three
preselecting a method or methods. The latter method is standard detrending options for each one (Fig. 2). The
useful to ensure replication. There are three standard user can decide which method to use using the keyboard
detrending methods: a modified negative exponential and the results (RWIs) are stored in the object
curve, cubic smoothing spline, or a horizontal line. wa082.rwi.
(Here and elsewhere in the paper, notation follows Cook Chronologies can also be built in dplR with the
et al. (1990) and Fritts (2001).) The modified negative chron function. This function builds a mean value
exponential curve fits a model Gt ¼ aebt+k where the chronology either by averaging each year’s RWI using
growth trend Gt is estimated as a function of time t with the arithmetic mean or using Tukey’s biweight robust
coefficients a, b, and k. If that nonlinear model cannot mean which minimizes the effects of outliers. Prewhi-
be fit, then a standard linear model is fit (Gt ¼ b0+b1t tened chronologies can also be built where autocorrela-
where b0 and b1 are the intercept and slope). The tion is removed from each series before averaging using
ARTICLE IN PRESS
118 A.G. Bunn / Dendrochronologia 26 (2008) 115–124
1.0
mm
0.5
0.0
0 50 100 150
Age (Yrs)
Spline
1.5
RWI
1.0
0.5
0.0
0 50 100 150
Age (Yrs)
2.0
1.5
RWI
1.0
0.5
0.0
0 50 100 150
Age (Yrs)
2.5
2.0
1.5
RWI
1.0
0.5
0.0
0 50 100 150
Age (Yrs)
Fig. 2. Series 712011 from the Hurricane Ridge dataset is shown here with three detrending options for interactive detrending.
ARTICLE IN PRESS
A.G. Bunn / Dendrochronologia 26 (2008) 115–124 119
HURstd
1.4
20
Sample Depth
1.2
RWI
15
1.0
10
0.8
0.6
Fig. 3. The standard chronology is shown for the Hurricane Ridge RWI data. A smoothing spline highlights low-frequency
variability and the sample depth is plotted on right-hand y-axis.
the R function ar. The prewhitening is performed by Table 2. Composite statistics produced by dplR function
fitting an autoregressive model to the data where the rwi.stats for the detrended and standardized Hurricane
complexity of the model is selected by Akaike’s Ridge data
information criterion (Venables and Ripley, 2002).
Statistic Value
A standard chronology of the Hurricane Ridge RWI
data (wa082.rwi) can be built with Ntot 253
Nwt 11
4wa082.crn o- chron(wa082.rwi, Nbt 242
prefix ¼ ‘‘HUR’’) r̄tot 0.244
r̄wt 0.47
The object wa082.crn has two columns with the r̄bt 0.233
first (wa082.crn$HUR) containing the chronology ceff 1.846
values and the second (wa082.crn$samp.depth) r̄eff 0.308
the number of samples for each year. The chronology eps 0.911
can be truncated to only have years with more than five Notation follows Cook et al. (1990).
samples using R’s subset function:
4wa082.trunc o- subset(wa082.crn,
samp.depth 45)
and standardized ring-width data from Hurricane
Ridge:
A plot of the chronology with the sample depth can be
produced using the crn.plot function (Fig. 3): 4wa082.idso-read.ids(wa082.rwi,
stc ¼ c(3, 2, 3))
4crn.plot(wa082.trunc) 4wa082.rwi.statso-rwi.stats(wa082.
rwi,ids ¼ wa082.ids)
This function takes advantage of R’s plotting ability
and is a relatively simple plot that is designed to be used The tree ids are read using the read.ids function
with the output of the chron function. and parses the series ids by site (3 characters, e.g.,
The rwi.stats function produces a variety of ‘‘712’’), tree (2 characters, e.g., ‘‘01’’, ‘‘02’’,y), and core
statistics that indicate the within-tree and between- (3 characters, e.g., ‘‘1’’, ‘‘2’’,y). The Hurricane Ridge
tree correlation (r̄) and expressed population signal data set has two cores per tree for all but one series (i.e.,
(Cook et al., 1990). Tree-ring data sets often ‘‘712111’’). The object wa082.stats contains within-
contain more than one sample per tree to analyze and between-tree correlations for maximum pairwise
within- versus between-tree variability. The read.ids overlap among the series (Table 2).
function allows the user to specify tree and core The output from dplR in terms of chronologies and
ids for each series by attempting to parse the descriptive statistics is very close to the output from
series identifications. For example, using the detrended traditional software in dendrochronology. For example,
ARTICLE IN PRESS
120 A.G. Bunn / Dendrochronologia 26 (2008) 115–124
Hurricane Ridge
Chronology
1.6 99% CI
Samples
20
1.4
Sample Depth
1.2
15
RWI
1.0
0.8
10
0.6
Fig. 4. The standard chronology is shown for the Hurricane Ridge RWI data, but this time with bootstrapped 99% confidence
intervals (1000 bootstrapped replicates were used).
D1 2yrs
D2 4yrs
D3 8yrs
D4 16yrs
D5 32yrs
D6 64yrs
Fig. 5. A multiresolution decomposition of the Hurricane Ridge chronology for seven wavelet details is shown with years
corresponding to the wavelet details shown on the right. Each wavelet detail is scaled independently by dividing it by the root-mean-
square.
Cook, E.R., Briffa, K., Shiyatov, S., Mazepa, A., Jones, P.D., North, G.R., Biondi, F., Bloomfield, P., Christy, J.R., Cuffey,
1990. Data analysis. In: Cook, E.R., Kairiukstis, L.A. K.M., Dickinson, R.E., Druffel, E.R.M., Nychka, D.,
(Eds.), Methods of Dendrochronology: Applications in the Otto-Bliesner, B., Roberts, N., Turekian, K.K., Wallace,
Environmental Sciences. Kluwer Academic Publishers, J.M., 2006. Surface Temperature Reconstructions for the
Dordrecht, pp. 97–162. Last 2000 Years. National Academies Press, Washington,
Fritts, H.C., 2001. Tree Rings and Climate. Blackburn Press, p. 145.
Caldwell, NJ, USA, p. 567. Pocernich, M., 2006. R’s role in the climate change debate.
Holmes, R.L., 1983. Computer assisted quality control in tree- Rnews 6/4, 17–18.
ring dating and measurement. Tree-Ring Bulletin 43, 69–78. R Development Core Team, 2007. R: a language and
Holmes, R.L., 1992. Dendrochronology Program Library, environment for statistical computing. R Foundation for
Instruction and Program Manual (January 1992 update). Statistical Computing, Vienna, Austria, ISBN 3-900051-07-0,
Laboratory of Tree-Ring Research, University of Arizona, URL /http://www.R-project.orgS.
Tucson, USA. Schweingruber, F., Briffa, K., 1983. Hurricane Ridge Data
Li, B., Nychka, D.W., Ammann, C.M., 2007. The ‘hockey Set. IGBP PAGES/World Data Center for Paleoclimatol-
stick’ and the 1990s: a statistical perspective on reconstruct- ogy Data Contribution Series 1983-WA082.RWL, NOAA/
ing hemispheric temperatures. Tellus A 59, 591–598. NCDC Paleoclimatology Program, Boulder, CO, USA.
Mallat, S.G., 1989. A theory for multiresolution signal decom- Venables, W.N., Ripley, B.D., 2002. Modern Applied Statis-
position: the wavelet representation. IEEE Transactions on tics with S, fourth ed. Springer, Berlin, p. 495.
Pattern Analysis and Machine Intelligence 11, 674–693. Whitcher, B., 2006. waveslim: basic wavelet routines for one-,
Meko, D., 2002. Tree-Ring MATLAB Toolbox. URL /http:// two- and three- dimensional signal processing. R package
www.mathworks.com/matlabcentral/S. version 1.6. URL /http://www.R-project.orgS.