[Dplr-commits] r1137 - in pkg/dplR: . R man vignettes

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Dec 13 00:34:52 CET 2018


Author: andybunn
Date: 2018-12-13 00:34:51 +0100 (Thu, 13 Dec 2018)
New Revision: 1137

Modified:
   pkg/dplR/ChangeLog
   pkg/dplR/R/ccf.series.rwl.R
   pkg/dplR/R/xdate.floater.R
   pkg/dplR/R/xskel.ccf.plot.R
   pkg/dplR/man/ccf.series.rwl.Rd
   pkg/dplR/man/xdate.floater.Rd
   pkg/dplR/man/xskel.ccf.plot.Rd
   pkg/dplR/vignettes/xdate-dplR.Rnw
Log:
more ccf changes.

Modified: pkg/dplR/ChangeLog
===================================================================
--- pkg/dplR/ChangeLog	2018-12-12 21:23:51 UTC (rev 1136)
+++ pkg/dplR/ChangeLog	2018-12-12 23:34:51 UTC (rev 1137)
@@ -1,5 +1,16 @@
 * CHANGES IN dplR VERSION 1.7.0
 
+File: xdate-dplR.Rnw
+----------------
+
+- Rewritten to explain new args in ccf.
+
+File: xskel.ccf.plot.R and .Rd
+----------------
+
+- Added new argument to allow user to specify whether a series or master gets 
+  passed to ccf as x. The convention was screwy.
+  
 File: ccf.series.rwl.R and .Rd
 ----------------
 

Modified: pkg/dplR/R/ccf.series.rwl.R
===================================================================
--- pkg/dplR/R/ccf.series.rwl.R	2018-12-12 21:23:51 UTC (rev 1136)
+++ pkg/dplR/R/ccf.series.rwl.R	2018-12-12 23:34:51 UTC (rev 1137)
@@ -3,7 +3,7 @@
                            seg.length = 50, bin.floor = 100, n = NULL,
                            prewhiten = TRUE, biweight = TRUE,
                            pcrit = 0.05, lag.max = 5, make.plot = TRUE,
-                           floor.plus1 = FALSE, series.x, ...) {
+                           floor.plus1 = FALSE, series.x = FALSE, ...) {
 
     ## Handle different types of 'series'
     tmp <- pick.rwl.series(rwl, series, series.yrs)

Modified: pkg/dplR/R/xdate.floater.R
===================================================================
--- pkg/dplR/R/xdate.floater.R	2018-12-12 21:23:51 UTC (rev 1136)
+++ pkg/dplR/R/xdate.floater.R	2018-12-12 23:34:51 UTC (rev 1137)
@@ -1,9 +1,7 @@
-xdate.floater <- function(rwl, series, series.name = NULL, min.overlap=50, n=NULL,prewhiten = TRUE, biweight=TRUE,
+xdate.floater <- function(rwl, series, series.name = "Unk", min.overlap=50, n=NULL,prewhiten = TRUE, biweight=TRUE,
                           method = c("spearman", "pearson", "kendall"),
                           make.plot = TRUE, return.rwl = FALSE, verbose = TRUE) {
   
-  
-  if(is.null(series.name)){ series.name <- "Unk" }
   method2 <- match.arg(method)
   # Trim series in case it has NA (e.g., submitted stright from the rwl)
   idx.good <- !is.na(series)

Modified: pkg/dplR/R/xskel.ccf.plot.R
===================================================================
--- pkg/dplR/R/xskel.ccf.plot.R	2018-12-12 21:23:51 UTC (rev 1136)
+++ pkg/dplR/R/xskel.ccf.plot.R	2018-12-12 23:34:51 UTC (rev 1137)
@@ -1,6 +1,6 @@
 xskel.ccf.plot <- function(rwl,series,series.yrs = as.numeric(names(series)),
          win.start, win.width=50, n = NULL, prewhiten = TRUE,
-         biweight = TRUE) {
+         biweight = TRUE, series.x = FALSE) {
   ## check to see that win.width is even
   if(as.logical(win.width %% 2)) stop("'win.width' must be even")
   if (win.width > 100) {
@@ -81,8 +81,14 @@
 
 
   ## ccf
-  ccf.early <- as.vector(ccf(x=series.early,y=master.early,lag.max=5,plot=FALSE)$acf)
-  ccf.late <- as.vector(ccf(x=series.late,y=master.late,lag.max=5,plot=FALSE)$acf)
+  if(series.x){
+    ccf.early <- as.vector(ccf(x=series.early,y=master.early,lag.max=5,plot=FALSE)$acf)
+    ccf.late <- as.vector(ccf(x=series.late,y=master.late,lag.max=5,plot=FALSE)$acf)
+  }
+  else{
+    ccf.early <- as.vector(ccf(x=master.early,y=series.early,lag.max=5,plot=FALSE)$acf)
+    ccf.late <- as.vector(ccf(x=master.late,y=series.late,lag.max=5,plot=FALSE)$acf)
+  }
   pcrit=0.05
   sig <- qnorm(1 - pcrit / 2) / sqrt(length(master.early))
   sig <- c(-sig, sig)

Modified: pkg/dplR/man/ccf.series.rwl.Rd
===================================================================
--- pkg/dplR/man/ccf.series.rwl.Rd	2018-12-12 21:23:51 UTC (rev 1136)
+++ pkg/dplR/man/ccf.series.rwl.Rd	2018-12-12 23:34:51 UTC (rev 1137)
@@ -64,10 +64,10 @@
   \code{ccf(x=master, y=series, lag.max=lag.max, plot=FALSE)} if \code{series.x} is 
   \code{FALSE} and as \code{ccf(x=series, y=master, lag.max=lag.max, plot=FALSE)} if 
   \code{series.x} is \code{TRUE}.  This argument was introduced in dplR version 1.7.0.
-  
   Different users have different expectations about how missing or extra rings are 
   notated. If \code{switch.x = FALSE} the behavior will be like COFECHA where a missing 
-  ring in a series produces a negative lag in the plot rather than a positive lag.
+  ring in a series produces a negative lag in the plot rather than a positive lag. See the 
+  crossdating vignette \code{xdate-dplR}for more information.
 
   Correlations are calculated for the first segment, then the
   second segment and so on.  Correlations are only calculated for segments with

Modified: pkg/dplR/man/xdate.floater.Rd
===================================================================
--- pkg/dplR/man/xdate.floater.Rd	2018-12-12 21:23:51 UTC (rev 1136)
+++ pkg/dplR/man/xdate.floater.Rd	2018-12-12 23:34:51 UTC (rev 1137)
@@ -6,7 +6,7 @@
   Pulls an undated series through a dated rwl file in order to try to establish dates
 }
 \usage{
-xdate.floater(rwl, series, min.overlap = 50, series.name =  NULL, n = NULL,
+xdate.floater(rwl, series, series.name = "Unk", min.overlap = 50, n = NULL,
              prewhiten = TRUE, biweight = TRUE,
              method = c("spearman", "pearson","kendall"),
              make.plot = TRUE,return.rwl = FALSE, verbose = TRUE)
@@ -16,6 +16,7 @@
     rows such as that produced by \code{\link{read.rwl}}. }
   \item{series}{ a \code{data.frame} with series as columns and years as
     rows such as that produced by \code{\link{read.rwl}}. }
+  \item{series.name}{ a \code{character} giving a name for the series. }
   \item{min.overlap}{ number }
   \item{n}{ \code{NULL} or an integral value giving the filter length
     for the \code{\link{hanning}} filter used for removal of low

Modified: pkg/dplR/man/xskel.ccf.plot.Rd
===================================================================
--- pkg/dplR/man/xskel.ccf.plot.Rd	2018-12-12 21:23:51 UTC (rev 1136)
+++ pkg/dplR/man/xskel.ccf.plot.Rd	2018-12-12 23:34:51 UTC (rev 1137)
@@ -8,7 +8,7 @@
 \usage{
 xskel.ccf.plot(rwl, series, series.yrs = as.numeric(names(series)),
                win.start, win.width = 50, n = NULL,
-               prewhiten = TRUE, biweight = TRUE)
+               prewhiten = TRUE, biweight = TRUE, series.x=FALSE)
 }
 \arguments{
   \item{rwl}{ a \code{data.frame} with series as columns and years as rows
@@ -30,6 +30,9 @@
     whitened using \code{\link{ar}}. }
   \item{biweight}{ \code{logical} flag.  If \code{TRUE} then a robust
     mean is calculated using \code{\link{tbrm}}. }
+  \item{series.x}{ \code{logical} flag indicating whether to make the \code{series}
+    the \code{x} argument to \code{\link{ccf}}. See Details. }
+
 }
 \details{
   This function produces a plot that is a mix of a skeleton plot and a
@@ -48,8 +51,18 @@
   years the percentage would be 100\%.
 
   The bottom panels show cross correlations for the first half (left)
-  and second half of the time series using function \code{\link{ccf}} as
-  \code{ccf(x=series,y=master,lag.max=5)}.
+  and second half of the time series using function \code{\link{ccf}}.
+  
+  The cross correlations are calculated calling
+  \code{\link{ccf}} as \cr
+  \code{ccf(x=master, y=series, lag.max=lag.max, plot=FALSE)} if \code{series.x} is 
+  \code{FALSE} and as \code{ccf(x=series, y=master, lag.max=lag.max, plot=FALSE)} if 
+  \code{series.x} is \code{TRUE}.  This argument was introduced in dplR version 1.7.0.
+  Different users have different expectations about how missing or extra rings are 
+  notated. If \code{switch.x = FALSE} the behavior will be like COFECHA where a missing 
+  ring in a series produces a negative lag in the plot rather than a positive lag. See the 
+  crossdating vignette \code{xdate-dplR}for more information.
+  
 
   The plot is built using the \link[grid]{Grid} package which
   allows for great flexibility in building complicated plots.  However,

Modified: pkg/dplR/vignettes/xdate-dplR.Rnw
===================================================================
--- pkg/dplR/vignettes/xdate-dplR.Rnw	2018-12-12 21:23:51 UTC (rev 1136)
+++ pkg/dplR/vignettes/xdate-dplR.Rnw	2018-12-12 23:34:51 UTC (rev 1137)
@@ -198,25 +198,27 @@
 \caption{Cross-correlations between series \code{643114} and the master 
 chronology are shown for each segment (30-year segments lagged by 15 years). 
 The series correlates well at lag 0 until the 1865--1894 bin and then at 
-lag +1 prior to 1865.}
+lag -1 prior to 1865.}
 \label{fig:ccf.plot}
 \end{figure}
 
 Figure~\ref{fig:ccf.plot} shows that 1865 to 1894 is the misdated part of 
-this series. The lag of +1 over a lag of 0 indicates that the series
+this series. The lag of -1 over a lag of 0 indicates that the series
 \code{643114} is missing a ring as it better correlates to the master 
-chronology with a one-year offset. \footnote{As of dplR version 1.60,
-the cross correlations in \code{ccf.series.rwl} are calculated calling
-\code{ccf(x=series, y=master, lag.max=lag.max, plot=FALSE)}. Note that
-prior to dplR version 1.60, the \code{master} was set as \code{x} and 
-the \code{series} as \code{y}. This was changed to be more in line with 
-user expectations so that a missing ring in a series produces a positive
-lag in the plot rather than a negative lag. This structure of this call
-does put the plots at odds with Figure 3 in \cite{Bunn2010} which is 
-unfortunate.}
+chronology with a one-year offset. \footnote{As of dplR version 1.7.0,
+the cross correlations in \code{ccf.series.rwl} can be calculated calling
+\code{ccf(x=series, y=master, lag.max=lag.max, plot=FALSE)} if \code{series.x = TRUE}. 
+Otherwise, the function is called \code{ccf(x=master, y=series, lag.max=lag.max, plot=FALSE)}.
+Note that prior to dplR version 1.60 the behavior of the function was to have 
+\code{series.x = FALSE} so that \code{master} was always set as \code{x} and 
+the \code{series} as \code{y}. From versions 1.6.0 to 1.6.9 the \code{x} and \code{y}
+arguments were reversed to be more in line with (some) user expectations that a missing 
+ring in a series would produce a positive lag in the plot rather than a negative lag. 
+This structure of calling the function this was does put the plots at odds with Figure 3 
+in \cite{Bunn2010} and with the text output from COFECHA. Thus, in true splitting the baby fashion, the argument \code{series.x} was introduced in version 1.7.0 making sure that everybody will be confused.}
 
 Using a smaller time window and shorter correlation segments we
-can try to further isolate the switch from correlation at lag 0 to lag +1.
+can try to further isolate the switch from correlation at lag 0 to lag -1.
 We will, of course, have to be very careful about using such short segments
 for correlation and be ready to adjust our expectations accordingly. 
 Fortunately, in this case the trees are so exquisitely sensitive that we can
@@ -238,7 +240,7 @@
 \end{figure}
 
 By 1879 the correlation between series \code{643114} and the master is solidly at 
-lag +1 (Figure~\ref{fig:ccf.plot2}). The 1870 to 1889 correlation is marginal 
+lag -1 (Figure~\ref{fig:ccf.plot2}). The 1870 to 1889 correlation is marginal 
 while the dating at 1880--1899 seems accurate (lag 0). This suggests that 
 the dating error is between 1879 and 1889.  
 
@@ -266,7 +268,7 @@
 of agreement between the skeleton bars for the series and master. The bottom
 panels show cross correlations for the first half (left) and second half of 
 the time series. In this case, the early period (1865--1884) shows a mismatch
-of the skeleton plot by one year coupled with a strong lag +1 correlation. }
+of the skeleton plot by one year coupled with a strong lag -1 correlation. }
 \label{fig:ccf.skel.plot}
 \end{figure}
 



More information about the Dplr-commits mailing list