EVOLUTION-MANAGER
Edit File: Next.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: Advance a Time Series</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 Next {quantmod}"><tr><td>Next {quantmod}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2> Advance a Time Series </h2> <h3>Description</h3> <p>Create a new series with all values advanced forward one period. The value of period 1, becomes the value at period 2, value at 2 becomes the original value at 3, etc. The opposite of <code>Lag</code>. <code>NA</code> is used to fill. </p> <h3>Usage</h3> <pre> Next(x, k = 1) ## S3 method for class 'quantmod.OHLC' Next(x,k=1) ## S3 method for class 'zoo' Next(x,k=1) ## S3 method for class 'data.frame' Next(x,k=1) ## S3 method for class 'numeric' Next(x,k=1) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p> vector or series to be advanced </p> </td></tr> <tr valign="top"><td><code>k</code></td> <td> <p> periods to advance </p> </td></tr> </table> <h3>Details</h3> <p>Shift series k-periods up, appending <code>NA</code>s to end of series. </p> <p>Specifically designed to handle <code>quantmod.OHLC</code> and <code>zoo</code> series within the <span class="pkg">quantmod</span> workflow. </p> <p>If no S3 method is found, a call to <code>lag</code> in <span class="pkg">base</span> is made, with the indexing reversed to shift the time series forward. </p> <h3>Value</h3> <p>The original <code>x</code> appended with <code>k</code> <code>NA</code>s and missing the leading <code>k</code> values. </p> <p>The returned series maintains the number of obs. of the original. </p> <p>Unlike <code>Lag</code>, only one value for <code>k</code> is allowed. </p> <h3>Note</h3> <p>This function's purpose is to get the “next” value of the data you hope to forecast, e.g. a stock's closing value at t+1. Specifically to be used within the <span class="pkg">quantmod</span> framework of <code>specifyModel</code>, as a functional wrapper to the LHS of the model equation. </p> <p>It is not magic - and thus will not get tomorrow's values... </p> <h3>Author(s)</h3> <p> Jeffrey A. Ryan </p> <h3>See Also</h3> <p><code><a href="specifyModel.html">specifyModel</a></code>, <code><a href="Lag.html">Lag</a></code> </p> <h3>Examples</h3> <pre> Stock.Close <- c(102.12,102.62,100.12,103.00,103.87,103.12,105.12) Close.Dates <- as.Date(c(10660,10661,10662,10665,10666,10667,10668),origin="1970-01-01") Stock.Close <- zoo(Stock.Close,Close.Dates) Next(Stock.Close) #one period ahead Next(Stock.Close,k=1) #same merge(Next(Stock.Close),Stock.Close) ## Not run: # a simple way to build a model of next days # IBM close, given todays. Technically both # methods are equal, though the former is seen # as more intuitive...ymmv specifyModel(Next(Cl(IBM)) ~ Cl(IBM)) specifyModel(Cl(IBM) ~ Lag(Cl(IBM))) ## End(Not run) </pre> <hr /><div style="text-align: center;">[Package <em>quantmod</em> version 0.4.20 <a href="00Index.html">Index</a>]</div> </body></html>