Lag                 package:quantmod                 R Documentation

_L_a_g _a _T_i_m_e _S_e_r_i_e_s

_D_e_s_c_r_i_p_t_i_o_n:

     Create a lagged series from data, with 'NA' used to fill.

_U_s_a_g_e:

     Lag(x, k = 1)

     ## S3 method for class 'quantmod.OHLC':
     Lag(x, k = 1)

     ## S3 method for class 'zoo':
     Lag(x, k = 1)

     ## S3 method for class 'data.frame':
     Lag(x, k = 1)

     ## S3 method for class 'numeric':
     Lag(x, k = 1)

_A_r_g_u_m_e_n_t_s:

       x: vector or series to be lagged 

       k: periods to lag. 

_D_e_t_a_i_l_s:

     Shift series k-periods down, prepending 'NA's to front of series.

     Specifically designed to handle 'quantmod.OHLC' and 'zoo' series
     within the 'quantmod' workflow.

     If no S3 method is found, a call to 'lag' in 'base' is made.

_V_a_l_u_e:

     The original 'x' prepended with 'k' 'NA's and missing the trailing
     'k' values.

     The returned series maintains the number of obs. of the original.

_N_o_t_e:

     This function differs from 'lag' by returning  the original series
     modified, as opposed to simply changing the time series
     properties.  It differs from the like named 'Lag' in the 'Hmisc'
     as it deals primarily with time-series like objects.

     It is important to realize that if there is no applicable method
     for 'Lag', the value returned will be from  'lag' in 'base'.  That
     is, coerced to ''ts'' if necessary, and subsequently shifted.

_A_u_t_h_o_r(_s):

     Jeffrey A. Ryan

_S_e_e _A_l_s_o:

     'lag'

_E_x_a_m_p_l_e_s:

     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)

     Lag(Stock.Close)        #lag by 1 period
     Lag(Stock.Close,k=1)    #same
     Lag(Stock.Close,k=1:3)  #lag 1,2 and 3 periods

