StylizedFacts            package:fBasics            R Documentation

_S_t_y_l_i_z_e_d _F_a_c_t_s

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

     A collection and description of functions to  investigate and to
     plot several stylized facts  of economic and financial return
     series. This  includes fat tails, autocorrelations, long  memory
     behavior, and the Taylor effect. 

     The functions to display stylized facts are:

       'acfPlot'         autocorrelation function plot,
       'pacfPlot'        partial autocorrelation function plot,
       'lacfPlot'        lagged autocorrelation function plot,
       'lmacfPlot'       long memory autocorrelation function plot,
       'logpdfPlot'      logarithmic density plots,
       'qqgaussPlot'     Gaussian quantile quantile plot,
       'scalinglawPlot'  scaling behavior plot,
       'teffectPlot'     Taylor effect plot.

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

     acfPlot(x, labels = TRUE, ...)
     pacfPlot(x, labels = TRUE, ...) 

     lacfPlot(x, n = 12, lag.max = 20, type = c("returns", "values"),
         labels = TRUE, ...)
     lmacfPlot(x, lag.max = max(2, floor(10*log10(length(x)))), ci = 0.95, 
         type = c("both", "acf", "hurst"), labels = TRUE, trace = TRUE, ...) 
         
     logpdfPlot(x, breaks = "FD", type = c("lin-log", "log-log"), 
         doplot = TRUE, labels = TRUE, ...)
         
     qqgaussPlot(x, span = 5, col = "steelblue", labels = TRUE, ...)

     scalinglawPlot(x, span = ceiling(log(length(x)/252)/log(2)), doplot = TRUE, 
         labels = TRUE, trace = TRUE, ...)

     teffectPlot(x, deltas = seq(from = 0.2, to = 3, by = 0.2), lag.max = 10, 
         ymax = NA, standardize = TRUE, labels = TRUE, ...)

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

  breaks: logpdfPlot] - 
           one of:  (1) a vector giving the breakpoints between
          histogram cells,  (2) a single number giving the number of
          cells for the histogram,  (3) a character string naming an
          algorithm to compute the number  of cells (The default for
          breaks is "FD". Other names for which  algorithms are
          supplied are "Scott", "Sturges" and "Freedman-Diaconis"), 
          (4) a function to compute the number of cells.  In the last
          three cases the number is a suggestion only.  

      ci: [lmacfPlot] - 
           the confidence interval, by default 95 percent, i.e. 0.95. 

     col: a character string denoting the plot color, by default
          '"steelblue"'. 

  deltas: [teffectPlot] - 
           the exponents, a numeric vector, by default ranging  from
          0.2 to 3.0 in steps of 0.2. 

  doplot: a logical value. Should a plot be displayed? 

  labels: a logical value. Whether or not x- and y-axes should be
          automatically  labeled and a default main title should be
          added to the plot. By default 'TRUE'. 

 lag.max: maximum lag for which the autocorrelation should be 
          calculated, an integer. 

       n: [lacfPlot] - 
           an integer value, the number of lags. 

    span: [scalinglawPlot] - 
           an integer value, determines for the 'qqgaussPlot' the  plot
          range, by default 5, and for the 'scalingPlot' a reasonable
          number of of points for the scaling range, by default daily
          data with 252 business days per year are assumed. 

standardize: [teffectPlot] - 
           a logical value. Should the vector 'x' be standardized? 

   trace: a logical value. Should the computation be traced? 

    type: [lacf] - 
           a character string which specifies the type of the input
          series, either "returns" or series "values". In the case of 
          a return series as input, the required value series is 
          computed by cumulating the financial returns: 
          'exp(colCumsums(x))',
           [lmacf] - 
           a character string, either '"both"', '"acf"', or  '"hurst"'
          denoting which type of plot should be generated:  an
          autocorrelation plot, a hurst plot, or both,
           [logpdf] - 
           a character string, either '"lin-log"', or '"log-log"' 
          denoting on which scale the plot will produced: on a linear
          vs.  log scale, or on a double logarithmic scale. 

       x: an uni- or multivariate return series of class 'timeSeries' 
          or any other object which can be transformed by the function
          'as.timeSeries()' into an object of class 'timeSeries'. 

    ymax: [teffectPlot] - 
           maximum y-axis value on plot, 'is.na(ymax)' TRUE, then the
          value is selected automatically. 

     ...: arguments to be passed. 

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

     *Tail Behavior:* 

      'logpdfPlot' and 'qqgaussPlot' are two simple functions which
     allow a quick view on the tails of a distribution. The first
     creates a logarithmic or  double-logarithmic density plot and
     returns breaks and counts. For the double logarithmic plot, the
     negative side of the distribution  is reflected onto the positive
     axis.
      The second creates a Gaussian Quantile-Quantile plot. 

     *Scaling Behavior:* 

      The function 'scalingPlot' plots the scaling law of financial 
     time series under aggregation and returns an estimate for the
     scaling  exponent. The scaling behavior is a very striking effect
     of the  foreign exchange market and also other markets expressing
     a regular structure for the volatility. Considering the average
     absolute return over individual data periods one finds a scaling
     power law which relates the mean volatility over given time
     intervals to the size of these intervals. The power law is in many
     cases  valid over several orders of magnitude in time. Its
     exponent   usually deviates significantly from a Gaussian random
     walk model  which implies 1/2.  

     *Autocorrelation Functions:* 

      The functions 'acfPlot' and 'pacfPlot', plot and estimate 
     autocorrelation and partial autocorrelation function. The
     functions  allow to get a first view on correlations within the
     time series.  The functions are synonyme function calls for R's
     'acf' and  'pacf' from the the 'ts' package. 

     *Long Memory Autocorrelation Function:* 

      The function 'lmacfPlot' plots and estimates the  long memory
     autocorrelation function and computes from the  plot the  Hurst
     exponent of a time series. The volatility of   financial time
     series exhibits (in contrast to the logarithmic returns) in almost
     every financial market a slow ecaying autocorrelation function,
     ACF. We talk of a long memory  if the decay in the ACF is slower
     than exponential, i.e. the  correlation function decreases
     algebraically with increasing  (integer) lag.  Thus it makes sense
     to investigate the decay on a double-logarithmic  scale and to
     estimate the decay exponent. The function 'lmacf' calculates and
     plots the autocorrelation function of  the vector 'x'. If the time
     series exhibits long memory  behaviour, it can easily be seen as a
     stright line in the plot.  This double-logarithmic plot is
     displayed and a linear regression  fit is done from which the
     intercept and slope ar calculated.  From the slope the Hurst
     exponent is derived. 

     *Taylor Effect:* 

      The "Taylor Effect" describes the fact that absolute returns of
     speculative assets have significant serial correlation over long
     lags. Even more, autocorrelations of absolute returns are
     typically greater than those of squared returns. From these 
     observations the Taylor effect states, that that the
     autocorrelations of absolute returns to the the power of 'delta', 
     'abs(x-mean(x))^delta' reach their maximum at 'delta=1'. The
     function 'teffect' explores this behaviour. A plot is created
     which shows for each lag (from 1 to 'max.lag') the 
     autocorrelations as a function of the exponent 'delta'.  In the
     case that the above formulated hypothesis is supported, all the
     curves should peak at the same value around 'delta=1'.

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

     'logpdfPlot' 
      returns a list with the following components: 'breaks', 
     histogram mid-point breaks; 'counts', histogram counts; 'fbreaks',
     fitted Gaussian breaks; 'fcounts', fitted  Gaussian counts. 

     'qqgaussPlot' 
      returns a Gaussian Quantile-Quantile Plot. 

     'scalinglawPlot' 
      returns a list with the following components: 'Intercept',
     'Exponent' the scaling exponent, and 'InverseExponent' its inverse
     value. 

     'acfPlot', 'pacfplot', 
      return an object of class '"acf"', see 'acf'. 

     'lmacfPlot' 
      returns a list with the following elements: 'fit', a list  by
     itself with elements 'Intercept' and slope 'X', 'hurst', the Hurst
     exponent, both are numeric values. 

     'lacfPlot' returns a list with the following two elements: 'Rho',
     the autocorrelation function, 'lagged', the lagged correlations. 

     'teffectPlot' 
      returns a numeric matrix of order 'deltas' by 'max.lag'  with the
     values of the autocorrelations.

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

     Diethelm Wuertz for the Rmetrics R-port.

_R_e_f_e_r_e_n_c_e_s:

     Taylor S.J. (1986);  _Modeling Financial Time Series_, John Wiley
     and Sons, Chichester.

     Ding Z., Granger C.W.J., Engle R.F. (1993);  _A long memory
     property of stock market returns and a new model_, Journal of
     Empirical Finance 1, 83.

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

        
     ## data - 
        # require(MASS)
        plot(SP500, type = "l", col = "steelblue", main = "SP500")
        abline(h = 0, col = "grey")
        
     ## qqgaussPlot -
        # Lagged Correlations:
        qqgaussPlot(SP500)

     ## teffectPlot -
        # Taylor Effect:
        teffectPlot(SP500)

