Download
r support for time series november 2012 n.
Skip this Video
Loading SlideShow in 5 Seconds..
R Support for Time Series November 2012 PowerPoint Presentation
Download Presentation
R Support for Time Series November 2012

R Support for Time Series November 2012

267 Vues Download Presentation
Télécharger la présentation

R Support for Time Series November 2012

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. R Support forTime SeriesNovember 2012 Stu Rodgers

  2. Installation and Set up • Install a version of R (http://www.r-project.org) • http://cran.us.r-project.org/bin/windows/base/ • Install and load the packages • install.packages(c(“xts"),repos=c("http://cran.us.r-project.org")) • library(“xts”) • install.packages(c(“tseries"),repos=c("http://cran.us.r-project.org")) • library(“tseries”) • install.packages(c(“chron"),repos=c("http://cran.us.r-project.org")) • library(“chron”) • Get the package references if desired • http://cran.us.r-project.org/web/packages/tseries/tseries.pdf • http://cran.us.r-project.org/web/packages/zoo/zoo.pdf • http://cran.us.r-project.org/web/packages/xts/xts.pdf • http://cran.us.r-project.org/web/packages/chron/chron.pdf • Reference • http://cran.us.r-project.org/web/views/TimeSeries.html

  3. Times and Dates Versus Data chron POSIXct character Time Classes Date yearqtr yearmon numeric timeDate POSIXlt fts matrix zoo ts timeSeries irts data.frame vector mts its Data Classes

  4. ts • in package stats • regularly spaced time series • well-suited for annual, monthly, quarterly data, etc.

  5. POSIX classes • POSIXct – seconds since the epoch • POSIXlt – list of components • sec, min, hour, mday, mon, year, wday, yday, isdat

  6. See R code

  7. zoo • Older classes vary in implementation • timeSeries, its, irts • restricted to particular class (1 each) for time scale • indexed by : timeDate, POSIXct • Provides more general support for ordered observations • index by : numeric, Date, POSIXct, etc • Provide methods to standard generic functions • simplify usage by conforming Z’s ordered observations, originally designed for package strucchange (Zeileis, et al)

  8. zoo • Create a zoo object • zoo(x, order.by) • x is vector or matrix • order.by is index by which the obs should be ordered • NROW(x) must equal length(order.by) • Standard generic functions • print, summary, str, head, tail, [ (subsetting), etc.

  9. See R code

  10. xts • zoo object inside • Why xts? • Growth of R and the challenge of choice • Prior coercion methods failed to maintain the original object's data in its entirety • Conversion from timeSeries to zoo : loss of FinCenter, format, recordIDs attributes, e.g. • Benefit to developers and users

  11. xts • Differences • formal time-based classes for indexing • Date, POSIXct, chron, yearmon, yearqtr, timeDate • internal xts properties • user-added attributes • other class’s specific attributes stored here during conversion

  12. xts • Standard generic functions • [, cbind, rbind, c, str, Ops, print, na.omit, time, index, plot, coredata • Subsetting • ISO:8601 time format “CCYY-MM-DD HH:MM:SS”

  13. See R code

  14. Questions • Stu Rodgers • 937-903-0558 • s.rodgers@tier1performance.com • All subject content for this presentation was obtained at http://www.r-project.org