[Dplr-commits] r819 - in pkg/dplR: . vignettes

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Apr 16 16:41:15 CEST 2014


Author: andybunn
Date: 2014-04-16 16:41:14 +0200 (Wed, 16 Apr 2014)
New Revision: 819

Modified:
   pkg/dplR/TODO
   pkg/dplR/vignettes/intro-dplR.Rnw
   pkg/dplR/vignettes/xdate-dplR.Rnw
Log:
* Editing of vignettes (ready to go I think)
* Mikko, see item on TODO and tell me what you think.

Modified: pkg/dplR/TODO
===================================================================
--- pkg/dplR/TODO	2014-04-16 10:49:27 UTC (rev 818)
+++ pkg/dplR/TODO	2014-04-16 14:41:14 UTC (rev 819)
@@ -1,3 +1,19 @@
+o[mvkorpel] In the crossdating functions that take foo(rwl,series) it would be nice to
+  have the user be able to use a series name or index instead of the rwl object
+  instead of subsetting the rwl object itself. For instance, right now to use
+  the ccf crossdating function a user does this:
+    data(co021)
+    dat <- co021
+    flagged <- dat$"641143"
+    names(flagged) <- rownames(dat)
+    dat$"641143" <- NULL
+    ccf.100 <- ccf.series.rwl(rwl = dat, series = flagged, seg.length = 100)
+
+  It would be better if they could just do this:
+    ccf.100 <- ccf.series.rwl(rwl = dat, series = "641143", seg.length = 100)
+  Or this:
+    ccf.100 <- ccf.series.rwl(rwl = dat, series.index = 4, seg.length = 100)
+
 o[mvkorpel]  Mikko, I started working on the verbose option for detrend.series. 
    There are some things to take care of in there that you can likely do
    better than I can.
@@ -7,17 +23,12 @@
 -  Also note that i.detrend will need fixing too for verbose mode.
 
 o[andybunn]  Write more vignettes:
--  Crossdating (started)
 -  Spectral and wavelets
 -  Advanced chronology building (strip.rwl, etc.)
 
-*  In rwi.stats and any place a correlation is calculated, offer an argument to
-   to specify which correlation method (e.g., spearman). Note that this is 
-   implemented in interseries.cor - but will have to do this throughout. 
-   The default should be spearman.
--   Did this in rwi.stats, corr.rwl.seg, and corr.series.seg but the 
-    output names still have "rho" in them. Change?
--   This can't be easily implemented in ccf.series.rwl
+*  Move the relative growth calculation in skel plot to its own function
+   called skel.calc. I want to make better use of skeleton plotting and the 
+   curent plot (while pretty) is not especially useful.
 
 * Decide when to use class('rwl') in functions dealing with rwl objects.
   Other than the plot and summary S3Method for rwl, are there cases when 

Modified: pkg/dplR/vignettes/intro-dplR.Rnw
===================================================================
--- pkg/dplR/vignettes/intro-dplR.Rnw	2014-04-16 10:49:27 UTC (rev 818)
+++ pkg/dplR/vignettes/intro-dplR.Rnw	2014-04-16 14:41:14 UTC (rev 819)
@@ -114,7 +114,7 @@
 <<a, fig=TRUE>>=
 plot(ca533, plot.type="spag")
 @
-\begin{figure}[htbp]
+\begin{figure}[h]
 \centering
 \includegraphics{intro-dplR-a}
 \caption{A spaghetti plot of the Campito Mountain ring widths.}
@@ -122,10 +122,10 @@
 \end{figure}
 
 \section{Detrending}
-Analysts typically (but not always) detrend a \code{rwl} data set to create a 
-ring-width index (rwi) object. The dplR package contains most standard 
-detrending methods including detrending via splines, fitting negative 
-exponential curves, and so on. There are also dplR functions for 
+Analysts typically (but not always) detrend a \code{rwl} data set to create 
+an object containing ring-width index (rwi) values. The dplR package contains 
+most standard detrending methods including detrending via splines, fitting 
+negative exponential curves, and so on. There are also dplR functions for 
 less commonly used detrending methods like regional curve standardization. 
 
 \textbf{By the way, if this is all new to you - you should stop reading this
@@ -187,9 +187,9 @@
 for educational purposes.
 
 Let's detrend a single series and apply more than one detrending method when we
-call it. We'll also call \code{detrend.series} using the verbose mode so that
+call it. We'll call \code{detrend.series} using the verbose mode so that
 we can see the parameters applied for each method. The \code{detrend.series} 
-function, produces a plot by default. See Figure~\ref{fig:detrend.series}.
+function, produces a plot by default (Figure~\ref{fig:detrend.series}).
 
 <<b, fig=TRUE>>=
 series <- ca533[, "CAM011"] # extract the series
@@ -197,7 +197,7 @@
 series.rwi <- detrend.series(y = series, y.name = "CAM011",
                              verbose=TRUE)
 @
-\begin{figure}[htbp]
+\begin{figure}[h]
 \centering
 \includegraphics{intro-dplR-b}
 \caption{Detrending a single series via mutiple methods.}
@@ -294,7 +294,7 @@
 <<c, fig=TRUE>>=
 plot(ca533.crn, add.spline=TRUE, nyrs=20)
 @
-\begin{figure}
+\begin{figure}[h]
 \centering
 \includegraphics{intro-dplR-c}
 \caption{Campito Mountain chronology with 20-year smoothing spline.}
@@ -353,7 +353,7 @@
 box()
 par(def.par)
 @
-\begin{figure}
+\begin{figure}[h]
 \centering
 \includegraphics{intro-dplR-d}
 \caption{Campito Mountain chronology using an EPS cutoff.}

Modified: pkg/dplR/vignettes/xdate-dplR.Rnw
===================================================================
--- pkg/dplR/vignettes/xdate-dplR.Rnw	2014-04-16 10:49:27 UTC (rev 818)
+++ pkg/dplR/vignettes/xdate-dplR.Rnw	2014-04-16 14:41:14 UTC (rev 819)
@@ -87,13 +87,13 @@
 mean(interseries.cor(dat)[,1])
 plot(dat, plot.type="spag")
 @
-\begin{figure}[htbp]
+\begin{figure}[h]
 \centering
 \includegraphics{xdate-dplR-a}
 \caption{A spaghetti plot of the Mesa Verde ring widths.}
 \label{fig:rwl.plot}
 \end{figure}
-
+\newpage
 To demonstrate how crossdating works in dplR, we will take this perfectly 
 lovely data set and corrupt the dating of one of the series. By doing so we 
 will be able to reenact one of the most common tasks of the dendrochronologist:
@@ -105,13 +105,13 @@
 # create a missing ring by deleting a random year of
 # growth in a random series
 set.seed(4576)
-i <- sample(x=1:nrow(dat),size=1) # 709
-j <- sample(x=1:ncol(dat),size=1) # 12 "643114"
+i <- sample(x=1:nrow(dat),size=1)
+j <- sample(x=1:ncol(dat),size=1)
 tmp <- dat[,j]
 tmp <- c(NA,tmp[-i])
 dat[,j] <- tmp
 @
-We've now deleted the ith observation from the jth core while making sure that 
+We've now deleted the $i^{th}$ observation from the $j^{th}$ core while making sure that 
 \code{dat} still has the appropriate numbers of rows. By sticking the NA at the
 start of the series it is as if we missed a ring while measuring.
 
@@ -126,51 +126,50 @@
 variation prior to the correlation analysis. The help file has abundant 
 details. Here will will look at overlapping 60 year segments. A plot is 
 produced by default with \code{corr.rwl.seg} (Figure~\ref{fig:corr.rwl.plot}).
+In the \code{corr.rwl.seg} plots each segment of each series 
+is shown and colored by its correlation with the master. Each series is 
+represented by two courses of lines with the bottom course adhering to the 
+bottom axis timeline and the top course matching the upper axis timeline. 
+Segments are colored according to the strength of the correlation between 
+that segment and the master chronology. Blue correlates well (p-values less 
+or equal to the user-set critical value) while potential dating problems 
+are indicated by the red segments (p-values greater than the user-set 
+critical value). Green lines show segments that do not completely overlap 
+the time period and thus have no correlations calculated. Our modified data 
+set indicates one series with dating problems.
 <<b, fig=TRUE>>=
 rwl.60 <- corr.rwl.seg(dat,seg.length=60,pcrit=0.01)
 @
-\begin{figure}[htbp]
+\begin{figure}[h]
 \centering
 \includegraphics{xdate-dplR-b}
 \caption{Each 60-year segment of each series in the  modified Mesa 
-Verde data set is shown and colored by its correlation with the master. 
-Each series is represented by two courses of lines with the bottom course 
-adhering to the bottom axis timeline and the top course matching the upper 
-axis timeline (60-year segments lagged by 30 years). Segments are colored 
-according to the strength of the correlation between that segment and the 
-master chronology. Blue correlates well (p-values less or equal to the 
-user-set critical value) while potential dating problems are indicated 
-by the red segments (p-values greater than the user-set critical value). 
-Green lines show segments that do not completely overlap the time period 
-and thus have no correlations calculated. Our modified data set indicates
-one series with dating problems.}
+Verde data set is shown and colored by its correlation with the master.
+Our modified data set indicates one series with dating problems.}
 \label{fig:corr.rwl.plot}
 \end{figure}
 
-The low correlation between series "643114" and the master indicates a dating 
+The low correlation between series ``643114'' and the master indicates a dating 
 problem (Figure~\ref{fig:corr.rwl.plot}). Now that we suspect a dating problem,
-let's take closer look at this problem child 
-(Figure~\ref{fig:corr.seg.plot}).
+let's take closer look at this problem child. Figure~\ref{fig:corr.seg.plot}
+shows that series 643114 begins to lose correlation with the master at the 
+end of the 19th century.
 
 <<c, fig=TRUE>>=
-# take the misdated series and remove it
-# from the rwl object
+# removed misdated series from the dat
 flagged <- dat$"643114"
 names(flagged) <- rownames(dat)
 dat$"643114" <- NULL
 # look at this series with a running correlation
 seg.60 <- corr.series.seg(rwl=dat,series=flagged,seg.length=60)
 @
-
-\begin{figure}[htbp]
+\begin{figure}[h]
 \centering
 \includegraphics{xdate-dplR-c}
 \caption{Correlations between series 643114 and the master chronology are 
-shown with horizontal lines according to the specified segments 
-(60-year segments lagged by 30 years). A centered running correlation with a 
-length of 60 years complements the segment correlations. The user-specified 
-critical level is show with a dashed line. Series 643114 begins to lose 
-correlation with the master at the end of the 19th century.}
+shown with horizontal lines according (60-year segments lagged by 30 years). 
+A centered running correlation with a length of 60 years complements the 
+segment correlations. The critical level is show with a dashed line.}
 \label{fig:corr.seg.plot}
 \end{figure}
 
@@ -180,21 +179,18 @@
 function to look at lagged correlations to see if we can spot the dating
 problem (Figure~\ref{fig:ccf.plot}).
 
-<<>>=
+<<d, fig=TRUE>>=
 win <- 1800:1960
 dat.yrs <- as.numeric(rownames(dat))
 dat.trunc <- dat[dat.yrs%in%win,]
 flagged.yrs <- as.numeric(names(flagged))
 flagged.trunc <- flagged[flagged.yrs%in%win]
 names(flagged.trunc) <- rownames(dat.trunc)
-@
-
-<<d, fig=TRUE>>=
 ccf.30 <- ccf.series.rwl(rwl=dat.trunc,series=flagged.trunc, 
                          seg.length=30,bin.floor=50)
 @
 
-\begin{figure}[htbp]
+\begin{figure}[h]
 \centering
 \includegraphics{xdate-dplR-d}
 \caption{Cross-correlations between the flagged series and the master 
@@ -203,6 +199,7 @@
 lag -1 prior to 1865.}
 \label{fig:ccf.plot}
 \end{figure}
+\newpage
 
 Figure~\ref{fig:ccf.plot} shows that 1865 to 1894 is the misdated part of 
 this series. Using a smaller time window and shorter correlation segments we
@@ -221,22 +218,23 @@
                          seg.length=20,bin.floor=0)
 @
 
-\begin{figure}[htbp]
+\begin{figure}[h]
 \centering
-\includegraphics{xdate-dplR-d}
+\includegraphics{xdate-dplR-e}
 \caption{Cross-correlations between the flagged series and the master 
-chronology at 20-year segments lagged by 10 years).}
+chronology at 20-year segments lagged by 10 years over 1850-1900.}
 \label{fig:ccf.plot2}
 \end{figure}
 
-By 1879 the correlation between \code{flagged} and the master solidly at 
+By 1879 the correlation between \code{flagged} and the master is solidly at 
 lag -1 (Figure~\ref{fig:ccf.plot2}). The 1870 to 1889 correlation is marginal 
-while the dating at 1880-1899 seems accurate. This strongly suggests that 
+while the dating at 1880-1899 seems accurate (lag 0). This suggests that 
 the dating error is between 1879 and 1889. At this point the analyst would
 go to the wood and take a good look at the core and see what they could
 find out. There are more heroic efforts that one could go to to figure out
 exactly where the dating problem might be but nothing ever takes the place of
 looking at the sample! 
+\newpage
 
 We have strong inference now that series 643114 is misdated somewhere in a ten
 year period around 1885. We have still not revealed whether this is correct



More information about the Dplr-commits mailing list