[Xts-commits] r647 - in pkg/xtsExtra: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jun 20 20:19:01 CEST 2012


Author: weylandt
Date: 2012-06-20 20:19:01 +0200 (Wed, 20 Jun 2012)
New Revision: 647

Added:
   pkg/xtsExtra/man/stl.xts.Rd
Modified:
   pkg/xtsExtra/NAMESPACE
   pkg/xtsExtra/R/StructTS.R
Log:
Added stl methods

Modified: pkg/xtsExtra/NAMESPACE
===================================================================
--- pkg/xtsExtra/NAMESPACE	2012-06-20 00:05:38 UTC (rev 646)
+++ pkg/xtsExtra/NAMESPACE	2012-06-20 18:19:01 UTC (rev 647)
@@ -7,11 +7,6 @@
 ## Analytics
 
 export("acf")
-# export("acf.xts")
-# export("pacf.xts")
-# export("acf.ts")
-# export("acf.default")
-
 S3method(acf, default)
 S3method(acf, xts)
 S3method(acf, ts)
@@ -29,7 +24,6 @@
 S3method(arima0, xts)
 
 export("StructTS")
-
 S3method(StructTS, default)
 S3method(StructTS, xts)
 
@@ -37,6 +31,10 @@
 S3method(HoltWinters, default)
 S3method(HoltWinters, xts)
 
+export("stl")
+S3method(stl, default)
+S3method(stl, xts)
+
 # WHY DON'T DEPENDENCIES COVER THESE IMPORTS? 
 import(stats)
 import(utils)

Modified: pkg/xtsExtra/R/StructTS.R
===================================================================
--- pkg/xtsExtra/R/StructTS.R	2012-06-20 00:05:38 UTC (rev 646)
+++ pkg/xtsExtra/R/StructTS.R	2012-06-20 18:19:01 UTC (rev 647)
@@ -19,6 +19,31 @@
   ans
 }
 
+stl<- function(x, ...){
+  UseMethod("stl")
+}
+
+stl.default <- function(x, ...){
+  ans <- stats::stl(x, ...)
+  ans[["call"]] <- match.call()
+  
+  ans
+}
+
+stl.xts <- function(x, ...){
+  check.xts.stats(x)
+  
+  ans <- stl(coredata(x[, 1, drop = FALSE]), ...)
+  
+  ans[["time.series"]] <- xts(ans[["time.series"]], time(x))
+  ans[["call"]] <- match.call()
+  
+  class(ans) <- c("xtsStl","stl")
+  
+  ans
+}
+
+
 HoltWinters <- function(x, ...){
   UseMethod("HoltWinters")
 }

Added: pkg/xtsExtra/man/stl.xts.Rd
===================================================================
--- pkg/xtsExtra/man/stl.xts.Rd	                        (rev 0)
+++ pkg/xtsExtra/man/stl.xts.Rd	2012-06-20 18:19:01 UTC (rev 647)
@@ -0,0 +1,25 @@
+\name{stl.xts}
+
+\alias{stl}
+\alias{stl.default}
+\alias{stl.xts}
+
+\title{ Loess Seasonal Decomposition for xts Objects }
+\description{Decompose a time series into seasonal, trend, and irregular components using \code{loess}.}
+\usage{
+  \method{stl}{xts}(x, ...)
+}
+\arguments{
+  \item{x}{ an \code{xts} object }
+  \item{...}{ additional arguments to be passed to the \code{stats} function which drives these methods.}
+}
+\details{
+  Currently little more than thin wrappers to \code{stats::stl} for \code{xts} objects. Will receive increased functionality going forward. See documentation of those functions for more information about the calculation mechanisms.
+}
+\value{A \code{stl} object with the residuals and fitted values coerced back to \code{xts} objects.}
+\author{ Michael Weylandt }
+
+\examples{
+  # Hopefully we don't break this
+  example("stl","stats")
+}
\ No newline at end of file



More information about the Xts-commits mailing list