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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jun 13 18:19:53 CEST 2012


Author: weylandt
Date: 2012-06-13 18:19:53 +0200 (Wed, 13 Jun 2012)
New Revision: 628

Added:
   pkg/xtsExtra/R/arima.R
   pkg/xtsExtra/man/arima.xts.Rd
Modified:
   pkg/xtsExtra/NAMESPACE
   pkg/xtsExtra/R/acf.R
Log:
Basic infrastructure for arima & arima0 (untested)

Modified: pkg/xtsExtra/NAMESPACE
===================================================================
--- pkg/xtsExtra/NAMESPACE	2012-06-13 15:54:20 UTC (rev 627)
+++ pkg/xtsExtra/NAMESPACE	2012-06-13 16:19:53 UTC (rev 628)
@@ -18,4 +18,14 @@
 
 S3method(pacf,xts)
 
+export("arima")
+
+S3method(arima, default)
+S3method(arima, xts)
+
+export("arima0")
+
+S3method(arima0, default)
+S3method(arima0, xts)
+
 ## Data frame capability
\ No newline at end of file

Modified: pkg/xtsExtra/R/acf.R
===================================================================
--- pkg/xtsExtra/R/acf.R	2012-06-13 15:54:20 UTC (rev 627)
+++ pkg/xtsExtra/R/acf.R	2012-06-13 16:19:53 UTC (rev 628)
@@ -3,21 +3,29 @@
 }
 
 # Why do we need this? Shouldn't this dispatch to acf.default?
-acf.ts <- stats::acf 
+acf.ts <- function(x, ...){
+  stats::acf(x, ...)
+} 
 
-acf.default <- stats::acf
+acf.default <- function(x, ...){
+  stats::acf(x, ...)
+}
 
 acf.xts <- function(x, ...){
-  if(!is.regular(x)) warning("Input series is not regular -- treating as such but methods may not be reliable.")
-  if(NCOL(x) > 1L) warning("Using only the first column.")
+  check.xts.stats(x)
   
   acf(coredata(x[,1, drop = FALSE]), ...)
   
 }
 
 pacf.xts <- function(x, lag.max, plot, na.action, ...){
-  if(!is.regular(x)) warning("Input series is not regular -- treating as such but methods may not be reliable.")
-  if(NCOL(x) > 1L) warning("Using only the first column.")
+  check.xts.stats(x)
   
   stats::pacf.default(coredata(x[,1, drop = FALSE]), lag.max, plot, na.action, ...)
 }
+
+check.xts.stats <- function(x){
+  if(!is.regular(x)) warning("Input series is not regular -- treating as such, but results may be unreliable.")
+  
+  if(NCOL(x) > 1L) warning("Using only the first column.")
+}
\ No newline at end of file

Added: pkg/xtsExtra/R/arima.R
===================================================================
--- pkg/xtsExtra/R/arima.R	                        (rev 0)
+++ pkg/xtsExtra/R/arima.R	2012-06-13 16:19:53 UTC (rev 628)
@@ -0,0 +1,39 @@
+arima <- function(x, ...){
+  UseMethod("arima")
+}
+
+arima.default <- function(x, ...){
+  stats::arima(x, ...)
+}
+
+arima.xts <- function(x, ...){
+  check.xts.stats(x)
+  
+  ans <- arima(x[, 1, drop = FALSE], ...)
+  
+  ans$residuals <- as.xts(ans$residuals, time(x))
+  
+  class(ans) <- c("xtsArima","Arima")
+  
+  ans
+}
+
+arima0 <- function(x, ...){
+  UseMethod("arima0")
+}
+
+arima0.default <- function(x, ...){
+  stats::arima(x, ...)
+}
+
+arima0.xts <- function(x, ...){
+  check.xts.stats(x)
+  
+  ans <- arima0(x[, 1, drop = FALSE], ...)
+  
+  ans$residuals <- as.xts(ans$residuals, time(x))
+  
+  class(ans) <- c("xtsarima0","arima0")
+  
+  ans
+}

Added: pkg/xtsExtra/man/arima.xts.Rd
===================================================================
--- pkg/xtsExtra/man/arima.xts.Rd	                        (rev 0)
+++ pkg/xtsExtra/man/arima.xts.Rd	2012-06-13 16:19:53 UTC (rev 628)
@@ -0,0 +1,25 @@
+\name{arima.xts}
+
+\alias{arima}
+\alias{arima.default}
+\alias{arima.xts}
+
+\alias{arima0}
+\alias{arima0.default}
+\alias{arima0.xts}
+
+
+\title{ ARIMA for xts Objects }
+\description{Autoregressive Integrated Moving Average models for xts objects}
+\usage{
+\method{arima}{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::arima} and \code{stats::arima0} for xts objects. Will receive increased functionality going forward. See documentation of those functions for more information about the calculation mechanisms.
+}
+\value{An \code{Arima} or \code{arima0} object as appropriate with the residuals coerced back to xts objects.}
+\author{ Michael Weylandt }
\ No newline at end of file



More information about the Xts-commits mailing list