[Dplr-commits] r791 - in pkg/dplR: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Apr 8 18:58:14 CEST 2014
Author: andybunn
Date: 2014-04-08 18:58:14 +0200 (Tue, 08 Apr 2014)
New Revision: 791
Modified:
pkg/dplR/R/detrend.series.R
pkg/dplR/TODO
pkg/dplR/man/detrend.Rd
pkg/dplR/man/detrend.series.Rd
Log:
made a start on method "Ar" in detrend. This needs some work I expect. The help files have not been worked on yet. I'll do that. Mikko, can you check code?
Modified: pkg/dplR/R/detrend.series.R
===================================================================
--- pkg/dplR/R/detrend.series.R 2014-04-08 16:24:39 UTC (rev 790)
+++ pkg/dplR/R/detrend.series.R 2014-04-08 16:58:14 UTC (rev 791)
@@ -1,12 +1,12 @@
`detrend.series` <-
function(y, y.name = "", make.plot = TRUE,
- method = c("Spline", "ModNegExp", "Mean"),
+ method = c("Spline", "ModNegExp", "Mean", "Ar"),
nyrs = NULL, f = 0.5, pos.slope = FALSE,
constrain.modnegexp = c("never", "when.fail", "always"))
{
stopifnot(identical(make.plot, TRUE) || identical(make.plot, FALSE),
identical(pos.slope, FALSE) || identical(pos.slope, TRUE))
- known.methods <- c("Spline", "ModNegExp", "Mean")
+ known.methods <- c("Spline", "ModNegExp", "Mean", "Ar")
constrain2 <- match.arg(constrain.modnegexp)
method2 <- match.arg(arg = method,
choices = known.methods,
@@ -133,7 +133,15 @@
} else {
do.mean <- FALSE
}
-
+ if("Ar" %in% method2){
+ ## Fit an ar model - aka prewhiten
+ Ar <- ar.func(y2)
+ resids$Ar <- Ar / mean(Ar,na.rm=TRUE)
+ do.ar <- TRUE
+ } else {
+ do.ar <- FALSE
+ }
+
resids <- data.frame(resids)
if(make.plot){
@@ -152,7 +160,8 @@
if(do.spline) lines(Spline, col="green", lwd=2)
if(do.mne) lines(ModNegExp, col="red", lwd=2)
if(do.mean) lines(Mean, col="blue", lwd=2)
-
+ if(do.ar) lines(Ar, col="purple", lwd=2)
+
if(do.spline){
plot(resids$Spline, type="l", col="green",
main=gettext("Spline", domain="R-dplR"),
@@ -177,6 +186,13 @@
ylab=gettext("RWI", domain="R-dplR"))
abline(h=1)
}
+ if(do.ar){
+ plot(resids$Ar, type="l", col="purple",
+ main=gettext("Ar", domain="R-dplR"),
+ xlab=gettext("Age (Yrs)", domain="R-dplR"),
+ ylab=gettext("RWI", domain="R-dplR"))
+ abline(h=1)
+ }
}
resids2 <- matrix(NA, ncol=ncol(resids), nrow=length(y))
Modified: pkg/dplR/TODO
===================================================================
--- pkg/dplR/TODO 2014-04-08 16:24:39 UTC (rev 790)
+++ pkg/dplR/TODO 2014-04-08 16:58:14 UTC (rev 791)
@@ -34,11 +34,9 @@
- Consider the benefits and drawbacks of creating classes for chonologies.
One benefit would be an S3 plot method for chronologies.
-* Add 'prewhiten' as a detrending method.
+* Continue work on "Ar" as a detrending method.
It would be nice to have a prewhitening option to detrend.series
- (and therefore dentrend) that returns white noise
- This could be as easy as:
- y <- detrend.series(x, method="Mean")
- y <- ar.func(y)
- return(y)
+ (and therefore dentrend) that returns white noise. This has been started but
+ needs more work. The help files have not been worked on beyond adding Ar as
+ a method.
Modified: pkg/dplR/man/detrend.Rd
===================================================================
--- pkg/dplR/man/detrend.Rd 2014-04-08 16:24:39 UTC (rev 790)
+++ pkg/dplR/man/detrend.Rd 2014-04-08 16:58:14 UTC (rev 791)
@@ -7,7 +7,7 @@
}
\usage{
detrend(rwl, y.name = names(rwl), make.plot = FALSE,
- method = c("Spline", "ModNegExp", "Mean"), nyrs = NULL,
+ method = c("Spline", "ModNegExp", "Mean", "Ar"), nyrs = NULL,
f = 0.5, pos.slope = FALSE,
constrain.modnegexp = c("never", "when.fail", "always"))
}
@@ -25,7 +25,7 @@
\item{method}{ a \code{character} vector to determine the detrending
methods. See details below. Possible values are all subsets of
- \code{c("Spline", "ModNegExp", "Mean")}. Defaults to using all the
+ \code{c("Spline", "ModNegExp", "Mean", "Ar")}. Defaults to using all the
available methods.}
\item{nyrs}{ a number giving the rigidity of the smoothing spline,
Modified: pkg/dplR/man/detrend.series.Rd
===================================================================
--- pkg/dplR/man/detrend.series.Rd 2014-04-08 16:24:39 UTC (rev 790)
+++ pkg/dplR/man/detrend.series.Rd 2014-04-08 16:58:14 UTC (rev 791)
@@ -7,7 +7,7 @@
}
\usage{
detrend.series(y, y.name = "", make.plot = TRUE,
- method = c("Spline", "ModNegExp", "Mean"),
+ method = c("Spline", "ModNegExp", "Mean", "Ar"),
nyrs = NULL, f = 0.5, pos.slope = FALSE,
constrain.modnegexp = c("never", "when.fail", "always"))
}
@@ -23,7 +23,7 @@
\item{method}{ a \code{character} vector to determine the detrending
methods. See details below. Possible values are all subsets of
- \code{c("Spline", "ModNegExp", "Mean")}. Defaults to using all the
+ \code{c("Spline", "ModNegExp", "Mean", "Ar")}. Defaults to using all the
available methods.}
\item{nyrs}{ a number giving the rigidity of the smoothing spline,
More information about the Dplr-commits
mailing list