EVOLUTION-MANAGER
Edit File: lag.zoo.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 zoo 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 lag.zoo {zoo}"><tr><td>lag.zoo {zoo}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Lags and Differences of zoo Objects</h2> <h3>Description</h3> <p>Methods for computing lags and differences of <code>"zoo"</code> objects. </p> <h3>Usage</h3> <pre> ## S3 method for class 'zoo' lag(x, k = 1, na.pad = FALSE, ...) ## S3 method for class 'zoo' diff(x, lag = 1, differences = 1, arithmetic = TRUE, na.pad = FALSE, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>a <code>"zoo"</code> object.</p> </td></tr> <tr valign="top"><td><code>k, lag</code></td> <td> <p>For <code>lag</code> the number of lags (in units of observations). Note the sign of <code>k</code> behaves as in <code><a href="../../stats/html/lag.html">lag</a></code>. For <code>diff</code> it is the number of backward lags used (or if negative the number of forward lags.</p> </td></tr> <tr valign="top"><td><code>differences</code></td> <td> <p>an integer indicating the order of the difference.</p> </td></tr> <tr valign="top"><td><code>arithmetic</code></td> <td> <p>logical. Should arithmetic (or geometric) differences be computed?</p> </td></tr> <tr valign="top"><td><code>na.pad</code></td> <td> <p>logical. If <code>TRUE</code> it adds any times that would not otherwise have been in the result with a value of <code>NA</code>. If <code>FALSE</code> those times are dropped.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>currently not used.</p> </td></tr> </table> <h3>Details</h3> <p>These methods for <code>"zoo"</code> objects behave analogously to the default methods. The only additional arguments are <code>arithmetic</code> in <code>diff</code> <code>na.pad</code> in <code>lag.zoo</code> which can also be specified in <code>diff.zoo</code> as part of the dots. Also, <code>"k"</code> can be a vector of lags in which case the names of <code>"k"</code>, if any, are used in naming the result. </p> <h3>Value</h3> <p>The lagged or differenced <code>"zoo"</code> object. </p> <h3>Note</h3> <p>Note the sign of <code>k</code>: a series lagged by a positive <code>k</code> is shifted <em>earlier</em> in time. </p> <p><code>lag.zoo</code> and <code>lag.zooreg</code> can give different results. For a lag of 1 <code>lag.zoo</code> moves points to the adjacent time point whereas <code>lag.zooreg</code> moves the time by <code>deltat</code>. This implies that a point in a <code>zoo</code> series cannot be lagged to a time point that is not already in the series whereas this is possible for a <code>zooreg</code> series. </p> <h3>See Also</h3> <p><code><a href="zoo.html">zoo</a></code>, <code><a href="../../stats/html/lag.html">lag</a></code>, <code><a href="../../base/html/diff.html">diff</a></code></p> <h3>Examples</h3> <pre> x <- zoo(11:21) lag(x, k = 1) lag(x, k = -1) # this pairs each value of x with the next or future value merge(x, lag1 = lag(x, k=1)) diff(x^3) diff(x^3, -1) diff(x^3, na.pad = TRUE) </pre> <hr /><div style="text-align: center;">[Package <em>zoo</em> version 1.8-11 <a href="00Index.html">Index</a>]</div> </body></html>