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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Apr 1 22:25:22 CEST 2014


Author: andybunn
Date: 2014-04-01 22:25:22 +0200 (Tue, 01 Apr 2014)
New Revision: 756

Added:
   pkg/dplR/R/series.rho.R
   pkg/dplR/man/series.rho.Rd
Modified:
   pkg/dplR/ChangeLog
   pkg/dplR/NAMESPACE
Log:
Adding new function to calculate overall correlation of a series to a maser in an rwl object. The help file needs a lot of work as does the code. This will be pulled into rwl.stats I think. My thinking on this is still a bit muddled.

Modified: pkg/dplR/ChangeLog
===================================================================
--- pkg/dplR/ChangeLog	2014-04-01 09:39:58 UTC (rev 755)
+++ pkg/dplR/ChangeLog	2014-04-01 20:25:22 UTC (rev 756)
@@ -1,5 +1,18 @@
 * CHANGES IN dplR VERSION 1.6.0
 
+File: NAMESPACE
+-------------------------
+- Added chron.plot to export list.
+- Added rho.series to export list.
+- Added rwl.plot as an S3Method.
+
+File: series.rho.R
+-------------------------
+- New function series.rho. This needs more work.
+  E.g., speed up via apply()? And need to integrate
+  into rwl.stats WITHOUT any new arguments being
+  added to rwl.stats. I like that function clean.
+
 File: read.compact.R
 -------------------------
 - Added class "rwl" to output object.
@@ -32,10 +45,6 @@
 -------------------------
 - Added class "rwl" to object.
 
-File: NAMESPACE
--------------------------
-- Added chron.plot to export list.
-- Added rwl.plot as an S3Method.
 
 File: rwl.plot.R
 -------------------------

Modified: pkg/dplR/NAMESPACE
===================================================================
--- pkg/dplR/NAMESPACE	2014-04-01 09:39:58 UTC (rev 755)
+++ pkg/dplR/NAMESPACE	2014-04-01 20:25:22 UTC (rev 756)
@@ -36,7 +36,7 @@
        series.rwl.plot, skel.plot, spag.plot, strip.rwl, tbrm,
        tridas.vocabulary, uuid.gen, wavelet.plot, wc.to.po,
        write.compact, write.crn, write.rwl, write.tridas,
-       write.tucson, chron.plot, plot.rwl)
+       write.tucson, chron.plot, plot.rwl, series.rho)
 
 S3method(print, redfit)
 S3method(plot, rwl)

Added: pkg/dplR/R/series.rho.R
===================================================================
--- pkg/dplR/R/series.rho.R	                        (rev 0)
+++ pkg/dplR/R/series.rho.R	2014-04-01 20:25:22 UTC (rev 756)
@@ -0,0 +1,16 @@
+series.rho <- function(rwl,n=NULL,prewhiten=TRUE,biweight=TRUE){
+    nseries <- ncol(rwl)
+    rho.df <- data.frame(rho=rep(NA,nseries),p.val=rep(NA,nseries))
+    rownames(rho.df) <- colnames(rwl)
+    for(i in 1:nseries){
+      tmp <- normalize.xdate(rwl=rwl[,-i],series=rwl[,i],
+                             n=n,prewhiten=prewhiten,biweight=biweight)
+      tmp <- data.frame(series=tmp$series,master=tmp$master)
+      mask <- rowSums(is.na(tmp)) == 0
+      tmp2 <- cor.test(tmp$series[mask], tmp$master[mask],
+                      method = "spearman", alternative = "greater")
+      rho.df[i,1] <- tmp2$estimate
+      rho.df[i,2] <- tmp2$p.val
+    }
+    rho.df
+}

Added: pkg/dplR/man/series.rho.Rd
===================================================================
--- pkg/dplR/man/series.rho.Rd	                        (rev 0)
+++ pkg/dplR/man/series.rho.Rd	2014-04-01 20:25:22 UTC (rev 756)
@@ -0,0 +1,46 @@
+\name{series.rho}
+\alias{series.rho}
+\title{ Calculate an individual indidual series correlation against a master chronology in an rwl object  }
+\description{
+  This function calculates the correlation between a series and a master chronology
+}
+\usage{
+  series.rho(rwl,n=NULL,prewhiten=TRUE,biweight=TRUE)
+}
+\arguments{
+  \item{rwl}{ an \code{rwl} object (or similar \code{data.frame}) }
+  \item{n}{ an \code{rwl} object (or similar \code{data.frame}) }
+  \item{prewhiten}{ an \code{rwl} object (or similar \code{data.frame}) }
+  \item{biweight}{ an \code{rwl} object (or similar \code{data.frame}) }
+}
+\details{
+  This calculates the Spearman's correlation on each series in a rwl object
+  against a master chronology built using every other series in that object.
+  Before the correlation is calculated every series is optionally detrended
+  with a hanning filter and/or the residuals from an ar model. This function
+  produces the same output of the "overall" portion of 
+  \code{\link{corr.rwl.seg}}. This function is called by 
+  \code{\link{rwl.stats}}. The mean rho value given is sometimes referred to as
+  the "overall interseries correlation"" or the "COFECHA interseries 
+  correlation." This output differs from the rbar statistic given by
+  \code{\link{rwi.stats}} in that rbar is the average correaltion of each series
+  compared to each series where this is the correlation between a series and a
+  master chronology.
+}
+\value{ a \code{data.frame} with rho values and p-values given from
+\code{\link{cor.test}}
+}
+\author{ Andy Bunn, patched and improved by Mikko Korpela  }
+\seealso{ \code{\link{rwl.stats}}, \code{\link{rwi.stats}} }
+\examples{data(co021)
+foo <- series.rho(co021)
+# compare to: 
+# corr.rwl.seg(rwl=co021)$overall
+
+# two measures of interseries correlation:
+bar <- rwi.stats(detrend(co021,method="ModNegExp"))
+bar$rbar.eff
+mean(foo[,1])
+
+}
+\keyword{ manip }



More information about the Dplr-commits mailing list