Delt                package:quantmod                R Documentation

_C_a_l_c_u_l_a_t_e _P_e_r_c_e_n_t _C_h_a_n_g_e

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

     Calculate the k-period percent difference within one series, or
     between two series.  Primarily used to calculate the percent
     change from one period to another of a given series, or to
     calculate the percent difference between two series over the full
     series.

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

     Delt(x1, x2 = NULL, k = 0, type = c("log", "arithmetic"))

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

      x1: _m x 1_ vector 

      x2: _m x 1_ vector 

       k: change over 'k'-periods. default k=1 when x2 is NULL. 

    type: type of difference. log (default) or arithmetic. 

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

     When called with only 'x1', the one period percent change of the
     series is returned by default. Internally this happens by copying
     x1 to x2. A two period difference would be specified with 'k=2'.

     If called with both 'x1' and 'x2', the difference between the two
     is returned.  That is, k=0. A one period difference would be
     specified by 'k=1'. 'k' may also be a vector to calculate more
     than one period at a time. The results will then be an m x
     length(k)

     Log differences are used by default: Lag = log(x2(t)/x1(t-k))

     Arithmetic differences are calculated: Lag = (x2(t) -
     x1(t-k))/x1(t-k)

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

     An matrix of 'length(x1)' rows and 'length(k)' columns.

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

     Jeffrey A. Ryan

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

     'OpOp' 'OpCl'

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

     Stock.Open <- c(102.25,102.87,102.25,100.87,103.44,103.87,103.00)
     Stock.Close <- c(102.12,102.62,100.12,103.00,103.87,103.12,105.12)

     Delt(Stock.Open)                    #one period pct. price change
     Delt(Stock.Open,k=1)                #same
     Delt(Stock.Open,type='arithmetic')  #using arithmetic differences

     Delt(Stock.Open,Stock.Close)        #Open to Close pct. change
     Delt(Stock.Open,Stock.Close,k=0:2)  #...for 0,1, and 2 periods

