Learn R Programming

tseriesEntropy (version 0.5-12)

Srho: Entropy Measure Of Serial And Cross Dependence

Description

Entropy based measure of serial and cross dependence for integer or categorical data. Implements a normalized version of the Hellinger/Matusita distance. As shown in the references the metric measure is a proper distance.

Usage

Srho(x, y, lag.max, stationary = TRUE, plot = TRUE, version = c("FORTRAN","R"), nor = FALSE)

Arguments

x, y
integer or factor time series objects or vectors. (y is missing in the univariate case).
lag.max
maximum lag at which to calculate Srho; default is round(N/4) where N is the number of observations.
stationary
logical. If TRUE assumes stationarity and computes marginal probabilities by using N observations. If FALSE uses N-k observations where k is the lag.
plot
logical. If TRUE (the default) Srho is plotted.
version
either "FORTRAN" or "R". FORTRAN version is the default and is preferred over the pure R version which is considerably slower but is included in case of portability issues.
nor
logical. If TRUE normalizes Srho with respect to its attainable maximum. Defaults to FALSE.

Value

.Data
vector of lag.max elements containing Srho computed at each lag.
lags
integer vector that contains the lags at which Srho is computed.
stationary
Object of class "logical": TRUE if the stationary version is computed.
data.type
Object of class "character": contains the data type.
notes
Object of class "character": additional notes.

Warning

Unlike ccf the lag k value returned by Srho(x,y) estimates Srho between x[t] and y[t+k]. The result is returned invisibly if plot is TRUE.

Details

Univariate version: serial entropy
Srho(x, lag.max,
stationary = TRUE, plot = TRUE, version = c("FORTRAN","R"), nor = FALSE)

Bivariate version: cross entropy
Srho(x, y, lag.max,
stationary = TRUE, plot = TRUE, version = c("FORTRAN","R"), nor = FALSE)

This implementation of the measure is normalized to take values in [0, 1]. Normalization is performed with respect to the maximum attainable value computed analytically. This makes the results of Srho comparable among different series.

References

Granger C. W. J., Maasoumi E., Racine J., (2004) A dependence metric for possibly nonlinear processes. Journal of Time Series Analysis, 25(5), 649--669.

Giannerini S., Maasoumi E., Bee Dagum E., (2015), Entropy testing for nonlinear serial dependence in time series, Biometrika, forthcoming http://doi.org/10.1093/biomet/asv007.

Maasoumi E., (1993) A compendium to information theory in economics and econometrics. Econometric Reviews, 12(2), 137--181.

See Also

See Also Srho.test. The function Srho.ts implements the same measure for numeric data.

Examples

Run this code

## UNIVARIATE VERSION
x <- as.integer(rbinom(n=20,size=4,prob=0.5))
Srho(x,lag.max=4)

## BIVARIATE VERSION
y <- as.integer(rbinom(n=20,size=4,prob=0.5))
Srho(x,y,lag.max=4)

## EXAMPLE  1: the effect of normalization
## computes the maximum attainable value by correlating x with itself

set.seed(12)
K    <- 5           # number of categories
smax <- 1-1/sqrt(K) # theoretical maximum under the uniform distribution
x    <- as.integer(sample(1:K,size=1e3,replace=TRUE)) # generates the sequence
S    <- Srho(x,x,lag.max=2,nor=FALSE,plot=FALSE)

plot(S,lwd=2,col=4)
abline(h=smax,col=2,lty=2)
text(x=-1,y=0.54,labels=paste("theoretical maximum = ",round(smax,4),sep=""),col=2)
text(x=-1,y=0.45,labels=paste("estimated maximum = ",round(S[3],4),sep=""),col=4)

Run the code above in your browser using DataLab