1\name{Next} 2\alias{Next} 3\alias{Next.quantmod.OHLC} 4\alias{Next.zoo} 5\alias{Next.data.frame} 6\alias{Next.numeric} 7\title{ Advance a Time Series } 8\description{ 9Create a new series with all values advanced forward one period. 10The value of period 1, becomes the value at period 2, 11value at 2 becomes the original value at 3, etc. The opposite 12of \code{Lag}. \code{NA} is used to fill. 13} 14\usage{ 15Next(x, k = 1) 16 17\method{Next}{quantmod.OHLC}(x,k=1) 18 19\method{Next}{zoo}(x,k=1) 20 21\method{Next}{data.frame}(x,k=1) 22 23\method{Next}{numeric}(x,k=1) 24 25} 26\arguments{ 27 \item{x}{ vector or series to be advanced } 28 \item{k}{ periods to advance } 29} 30\details{ 31Shift series k-periods up, appending \code{NA}s to end of series. 32 33Specifically designed to handle \code{quantmod.OHLC} and 34\code{zoo} series within the \pkg{quantmod} workflow. 35 36If no S3 method is found, a call to \code{lag} in \pkg{base} is made, 37with the indexing reversed to shift the time series forward. 38} 39\value{ 40The original \code{x} appended with \code{k} \code{NA}s and 41missing the leading \code{k} values. 42 43The returned series maintains the number of obs. of the original. 44 45Unlike \code{Lag}, only one value for \code{k} is allowed. 46} 47\author{ Jeffrey A. Ryan } 48\note{ 49This function's purpose is to get the \dQuote{next} value of 50the data you hope to forecast, e.g. a stock's closing value 51at t+1. Specifically to be used within 52the \pkg{quantmod} framework of \code{specifyModel}, as a 53functional wrapper to the LHS of the model equation. 54 55It is not magic - and thus will not get tomorrow's values\ldots 56} 57\seealso{ \code{\link{specifyModel}}, \code{\link{Lag}} } 58\examples{ 59Stock.Close <- c(102.12,102.62,100.12,103.00,103.87,103.12,105.12) 60Close.Dates <- as.Date(c(10660,10661,10662,10665,10666,10667,10668),origin="1970-01-01") 61Stock.Close <- zoo(Stock.Close,Close.Dates) 62 63Next(Stock.Close) #one period ahead 64Next(Stock.Close,k=1) #same 65 66merge(Next(Stock.Close),Stock.Close) 67 68\dontrun{ 69# a simple way to build a model of next days 70# IBM close, given todays. Technically both 71# methods are equal, though the former is seen 72# as more intuitive...ymmv 73specifyModel(Next(Cl(IBM)) ~ Cl(IBM)) 74specifyModel(Cl(IBM) ~ Lag(Cl(IBM))) 75} 76} 77\keyword{ misc } 78\keyword{ datagen } 79