Learn R Programming

fBasics (version 240.10067)

StylizedFacts: Stylized Facts

Description

A collection and description of functions to investigate and to plot several stylized facts of economic and financial time series. This includes fat tails, autocorrelations, crosscorrelations, long memory behavior, and the Taylor effect. The functions to display stylized facts are: ll{ acfPlot autocorrelation function plot, pacfPlot partial autocorrelation function plot, ccfPlot cross correlation 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. }

Usage

acfPlot(x, labels = TRUE, ...)
pacfPlot(x, labels = TRUE, ...)
ccfPlot(x, y, lag.max = max(2, floor(10*log10(length(x)))), type = 
    c("correlation", "covariance", "partial"), labels = TRUE, ...) 
lacfPlot(x, n = 12, lag.max = 20, labels = TRUE, ...)
lmacfPlot(x, lag.max = max(2, floor(10*log10(length(x)))), ci = 0.95, 
    type = c("both", "acf", "hurst"), labels = TRUE, details = TRUE, ...) 
logpdfPlot(x, n = 50, type = c("lin-log", "log-log"), doplot = TRUE, 
    labels = TRUE, ...)
qqgaussPlot(x, span = 5, col = "steelblue4", labels = TRUE, ...)
scalinglawPlot(x, span = ceiling(log(length(x)/252)/log(2)), doplot = TRUE, 
    labels = TRUE, details = TRUE, ...)
teffectPlot(x, deltas = seq(from = 0.2, to = 3, by = 0.2), lag.max = 10, 
    ymax = NA, standardize = TRUE, labels = TRUE, ...)

Arguments

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?
details
a logical value. Should the results be printed?
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. [logpdfPlot] - an integer value, the number of break and count points.
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 wit
standardize
[teffectPlot] - a logical value. Should the vector x be standardized?
type
[ccfPlot] - a character string, either "correlation", "covariance", or "partial" denoting which type of correlation should be plotted, [lmacf] - a character string, either "both",
x, y
numeric vectors, univariate time series objects, or any other object which can be transformed by the function as.vector into a numeric vector.
ymax
[teffectPlot] - maximum y-axis value on plot, is.na(ymax) TRUE, then the value is selected automatically.
...
arguments to be passed.

Value

  • 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. 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.

Details

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.

References

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.

Examples

Run this code
## SOURCE("fBasics.3B-StylizedFacts")
   par(ask = FALSE)
   
## 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)

Run the code above in your browser using DataLab