EVOLUTION-MANAGER
Edit File: diff.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Lags and Differences of xts Objects</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for diff.xts {xts}"><tr><td>diff.xts {xts}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2> Lags and Differences of xts Objects </h2> <h3>Description</h3> <p>Methods for computing lags and differences on <code>xts</code> objects. This matches most of the functionality of <span class="pkg">zoo</span> methods, with some default argument changes. </p> <h3>Usage</h3> <pre> ## S3 method for class 'xts' lag(x, k = 1, na.pad = TRUE, ...) ## S3 method for class 'xts' diff(x, lag = 1, differences = 1, arithmetic = TRUE, log = FALSE, na.pad = TRUE, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p> an <code>xts</code> object </p> </td></tr> <tr valign="top"><td><code>k</code></td> <td> <p> period to lag over </p> </td></tr> <tr valign="top"><td><code>lag</code></td> <td> <p> period to difference over </p> </td></tr> <tr valign="top"><td><code>differences</code></td> <td> <p> order of differencing </p> </td></tr> <tr valign="top"><td><code>arithmetic</code></td> <td> <p> should arithmetic or geometric differencing be used </p> </td></tr> <tr valign="top"><td><code>log</code></td> <td> <p> should (geometric) log differences be returned </p> </td></tr> <tr valign="top"><td><code>na.pad</code></td> <td> <p> pad vector back to original size </p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p> additional arguments </p> </td></tr> </table> <h3>Details</h3> <p>The primary motivation for having methods specific to <code>xts</code> was to make use of faster C-level code within xts. Additionally, it was decided that <code>lag</code>'s default behavior should match the common time-series interpretation of that operator — specifically that a value at time ‘t’ should be the value at time ‘t-1’ for a positive lag. This is different than <code>lag.zoo</code> as well as <code>lag.ts</code>. </p> <p>Another notable difference is that <code>na.pad</code> is set to TRUE by default, to better reflect the transformation visually and within functions requiring positional matching of data. </p> <p>Backwards compatability with zoo can be achieved by setting <code>options(xts.compat.zoo.lag=TRUE)</code>. This will change the defaults of lag.xts to k=-1 and na.pad=FALSE. </p> <h3>Value</h3> <p>An <code>xts</code> object reflected the desired lag and/or differencing. </p> <h3>Author(s)</h3> <p> Jeffrey A. Ryan </p> <h3>References</h3> <p><a href="https://en.wikipedia.org/wiki/Lag">https://en.wikipedia.org/wiki/Lag</a> </p> <h3>Examples</h3> <pre> x <- xts(1:10, Sys.Date()+1:10) lag(x) # currently using xts-style positive k lag(x, k=2) lag(x, k=-1, na.pad=FALSE) # matches lag.zoo(x, k=1) diff(x) diff(x, lag=1) diff(x, diff=2) diff(diff(x)) </pre> <hr /><div style="text-align: center;">[Package <em>xts</em> version 0.12.2 <a href="00Index.html">Index</a>]</div> </body></html>