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 plot  several
     stylized facts of financial and economic  time series. This
     includes fat tails, autocorrelations,  crosscorrelations, long
     memory behavior, and the Taylor effect. 

     The functions are:

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

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

     logpdfPlot(x, n = 50, doplot = TRUE, type = c("lin-log", "log-log"), ...)
     qqgaussPlot(x, span = 5, col = "steelblue4", main = "Normal Q-Q Plot", ...)
     scalinglawPlot(x, span = ceiling(log(length(x)/252)/log(2)), doplot = TRUE, ...)
     acfPlot(x, ...)
     pacfPlot(x, ...)
     ccfPlot(x, y, ...)
     lmacfPlot(x, lag.max = 50, ci = 0.95, main = "ACF", doprint = TRUE)
     teffectPlot(x, deltas = seq(from = 0.2, to = 3, by = 0.2), lag.max = 10, 
         ymax = NA, standardize = TRUE)

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

      ci: the confidence interval, by default 95 percent, i.e. 0.95. 

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

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

  doplot: a logical. Should a plot be displayed? 

 doprint: a logical, should the results be printed? 

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

    main: a character string, the title of the plot. 

       n: an integer, the number of break and count points. 

    type: a character, either 'e' for "exceedences", 'd'  for
          "distances", or by default 'b' for "both",  selecting which
          plot should be displayed. 

    span: 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: a logical. Should the vector 'x' be standardized? 

    x, y: a numeric vector; for 'acfPlot', 'pacfPlot' and  'ccfPlot' a
          numeric vector or matrix or a univariate or  multivariate
          (not 'ccf') time series object. 

    ymax: maximum y-axis value on plot, is.na(ymax) TRUE the  value is
          selected automatically. 

     ...: for 'tsPlot' one or more univariate or multivariate time 
          series, else other 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', 'pacfPlot', and 'ccfPlot' plots and
     estimate autocorrelation, ACF, partial autocorrelation,  PACF, and
     cross-covariance and cross-correlation functions, CCF.  The
     functions allow to get a first view on correlations in and 
     between time series. The functions are synonyme function  calls
     for R's 'acf', 'pacf', and 'ccf' 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. 

     'scalingPlot' 
      returns a list with the following components: 'exponent', the
     scaling exponent, a numeric value; 'fit', a list with  the
     coefficients returned by 'lsfit', i.e. 'intercept'  and 'X'. 

     'acfPlot', 'pacfplot', 'ccfPlot' 
      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. 

     '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
     proerty of stock market returns and a new model_, Journal of
     Empirical Finance 1, 83.

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

     ## logpdfPlot -
        xmpBasics("\nStart: log PDF Plot > ")
        # Plot the log-returns of the NYSE Composite Index
        # and compare with the Gaussian Distribution:  
        par(mfrow = c(2, 2))
        data(nyseres)
        # Extract from data.frame:
        x = nyseres[, 1]
        logpdfPlot(x, main = "log PDF Plot")
        # loglogpdfPlot -
        # Plot the log-returns of the NYSE Composite Index
        # and compare with the Gaussian Distribution:
        logpdfPlot(x, type = "log-log", main = "log-log PDF Plot")
        
     ## qqgaussPlot -
        xmpBasics("\nNext: QQ Normal Plot > ")
        # Create a Gaussian Quantile-Quantile plot
        # for the NYSE Composite Index log-returns:
        qqgaussPlot(x)
        
     ## scalinglawPlot -
        xmpBasics("\nNext: Scaling Law  Plot > ")
        # Investigate and Plot the Scaling Law
        # for the NYSE Composite Index log-returns:
        scalinglawPlot(x)
         
     ## acfPlot -
        xmpBasics("\nNext: Auto-Correlation Function Plot > ")
        data(EuStockMarkets)
        par(mfrow = c(2, 1))
        returns.ftse = diff(log(EuStockMarkets[,"FTSE"]))
        returns.dax = diff(log(EuStockMarkets[,"DAX"]))
        acfPlot(x = returns.ftse, main = "FTSE Autocorrelation")
        
     ## ccfPlot -
        xmpBasics("\nNext: Cross-Correlation Function Plot > ")
        ccfPlot(x = returns.ftse, y = returns.dax,
          main="FTSE - DAX Crosscorrelation")

     ## lmacfPlot -
        xmpBasics("\nNext: Long-Memory ACF Plot > ")
        # Estimate and plot the Long Memory ACF of the DAX volatilities
        # and evaluate the Hurst exponent of a time series:
        par(mfrow = c(2, 1))
        lmacfPlot(abs(returns.dax), main = "DAX")
        
     ## teffectPlot -
        xmpBasics("\nNext: Taylor Effect Plot > ")
        # Estimate and plot the Taylor Effect for the
        # log returns of the NYSE Compositie Index.
        teffectPlot(returns.dax)
        teffectPlot(returns.ftse)

