acf                  package:stats                  R Documentation

_A_u_t_o- _a_n_d _C_r_o_s_s- _C_o_v_a_r_i_a_n_c_e _a_n_d -_C_o_r_r_e_l_a_t_i_o_n _F_u_n_c_t_i_o_n _E_s_t_i_m_a_t_i_o_n

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

     The function 'acf' computes (and by default plots) estimates of
     the autocovariance or autocorrelation function.  Function 'pacf'
     is the function used for the partial autocorrelations.  Function
     'ccf' computes the cross-correlation or cross-covariance of two
     univariate series.

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

     acf(x, lag.max = NULL,
         type = c("correlation", "covariance", "partial"),
         plot = TRUE, na.action = na.fail, demean = TRUE, ...)

     pacf(x, lag.max, plot, na.action, ...)

     ## Default S3 method:
     pacf(x, lag.max = NULL, plot = TRUE, na.action = na.fail, 
         ...) 

     ccf(x, y, lag.max = NULL, type = c("correlation", "covariance"),
         plot = TRUE, na.action = na.fail, ...)

     acf.obj[i, j]

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

    x, y: a univariate or multivariate (not 'ccf') numeric time series
          object or a numeric vector or matrix.

 lag.max: maximum number of lags at which to calculate the acf. Default
          is 10*log10(N/m) where N is the number of observations and m
          the number of series.

    type: character string giving the type of acf to be computed.
          Allowed values are '"correlation"' (the default),
          '"covariance"' or '"partial"'.

    plot: logical. If 'TRUE' (the default) the acf is plotted.

na.action: function to be called to handle missing values. 'na.pass'
          can be used.

  demean: logical.  Should the covariances be about the sample means?

     ...: further arguments to be passed to 'plot.acf'.

 acf.obj: an object of class '"acf"' resulting from a call to 'acf'.

       i: a set of lags to retain.

       j: a set of series to retain.

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

     For 'type' = '"correlation"' and '"covariance"', the estimates are
     based on the sample covariance.

     By default, no missing values are allowed.  If the 'na.action'
     function passes through missing values (as 'na.pass' does), the
     covariances are computed from the complete cases.  This means that
     the estimate computed may well not be a valid autocorrelation
     sequence, and may contain missing values.  Missing values are not
     allowed when computing the PACF of a multivariate time series.

     The partial correlation coefficient is estimated by fitting
     autoregressive models of successively higher orders up to
     'lag.max'.

     The generic function 'plot' has a method for objects of class
     '"acf"'.

     The lag is returned and plotted in units of time, and not numbers
     of observations.

     There are 'print' and subsetting methods for objects of class
     '"acf"'.

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

     An object of class '"acf"', which is a list with the following
     elements:

     lag: A three dimensional array containing the lags at which the
          acf is estimated.

     acf: An array with the same dimensions as 'lag' containing the
          estimated acf.

    type: The type of correlation (same as the 'type' argument).

  n.used: The number of observations in the time series.

  series: The name of the series 'x'.

  snames: The series names for a multivariate time series.


     The result is returned invisibly if 'plot' is 'TRUE'.

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

     Original: Paul Gilbert, Martyn Plummer. Extensive modifications
     and univariate case of 'pacf' by B.D. Ripley.

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

     'plot.acf'

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

     ## Examples from Venables & Ripley
     acf(lh)
     acf(lh, type = "covariance")
     pacf(lh)

     acf(ldeaths)
     acf(ldeaths, ci.type = "ma")
     acf(ts.union(mdeaths, fdeaths))
     ccf(mdeaths, fdeaths) # just the cross-correlations.

     presidents # contains missing values
     acf(presidents, na.action = na.pass)
     pacf(presidents, na.action = na.pass)

