# amif

##### Auto Mutual Information Function

Computes and optionally plots the sample (normalized) auto mutual
information function of `x`

up to lag `lag.max`

.

- Keywords
- ts

##### Usage

```
amif(x, lag.max = NULL, maxbit = 20, confidence = 0.2, ci = 0.95,
nsurr = 20, fft = FALSE, amplitude = FALSE, normalized = TRUE,
trace = FALSE, plot = TRUE, ...)
```

##### Arguments

- x
- a numeric vector or time series.
- lag.max
- a scalar lag parameter.
- maxbit
- the maximum resolution in bit to which the precision of the data will be limited; also limits the maximum partition depth. It cannot exceed an overall maximum of 25 bit.
- confidence
- the confidence level for the chi-square-test which tests the point distribution in substructures of the probability area upon uniformity. A substructure is assumed if the deviation from a uniform point distribution occurs with a probability
- ci
- coverage probability for confidence bound. Plotting of
the confidence bound is suppressed if
`ci`

is zero or negative. - nsurr
- the number of surrogate samples to compute the confidence
bound. To obtain "good" confidence bounds, set
`nsurr`

to at least a value of`500`

. - fft
- a logical indicating whether phase randomized surrogate data is generated.
- amplitude
- a logical indicating whether amplitude-adjusted surrogate data is computed.
- normalized
- a logical indicating whether the normalized auto mutual information function is computed.
- trace
- a logical indicating whether additional output from the computation is traced.
- plot
- a logical indicating whether the AMIF is plotted.
- ...
- additional arguments to the plot methods for objects of
class
`"amif"`

(`plot.amif`

) or class`"acf"`

(`plot.acf`

).

##### Details

If `plot`

is `TRUE`

, then the AMIF is plotted. Further, the
confidence bound for the null of surrogate data is computed by
Monte-Carlo simulation percentiles and plotted. If any temporal
dependence is under question, then the null is an i.i.d. series and
scrambled surrogates can be used (the default). In the case of
testing non-linearity against linearity, setting the switch `fft`

is appropriate. It generates surrogates with the same spectrum as
`x`

. If the switch `amplitude`

is set in addition, then
surrogates `xs`

with the following properties are used: First,
`xs`

has the same histogram as `x`

. Second, `G(xs)`

has
the same Fourier spectra as `G(x)`

, where `G(.)`

is the
transformation from the histogram of `x`

to a Gaussian
distribution.

The simulations are computed with the actual values of `maxbit`

and `confidence`

.

Missing values are not allowed.

To compute the mutual information between two random variables, an implementation of the algorithm of Fraser and Swinney (1986) is used.

##### Value

- An object of class
`c("amif", "acf")`

.

##### References

C. Granger and J. L. Lin (1994):
Using the Mutual Information Coefficient to Identify Lags in
Non-Linear Models.
*Journal of Time Series Analysis* **15**, 371--384.

A. M. Fraser and H. L. Swinney (1986):
Independent Coordinates for Strange Attractors from Mutual
Information.
*Physical Review A* **33**, 1134--1140.

##### See Also

##### Examples

```
n <- 1000 # Length of simulated time series
e <- rnorm(n) # Generate ARCH(1) process
x <- double(n)
x[1] <- rnorm(1)
for(i in 2:n) {
x[i] <- e[i] * sqrt(0.1+0.4*x[i-1]^2)
}
x <- ts(x)
plot(x)
# Each test takes about 3 sec on a Pentium II 300MHz
amif(x, lag.max=5) # i.i.d. vs. any dependence
amif(x, lag.max=5, fft=TRUE) # linear vs. non-linear
amif(x, lag.max=5, fft=TRUE, amplitude=TRUE)
e <- rnorm(n) # Generate AR(1) process
x <- double(n)
x[1] <- rnorm(1)
for(i in 2:n)
{
x[i] <- 0.4*x[i-1]+e[i]
}
x <- ts(x)
plot(x)
amif(x, lag.max=5) # i.i.d. vs. any dependence
amif(x, lag.max=5, fft=TRUE) # linear vs. non-linear
amif(x, lag.max=5, fft=TRUE, amplitude=TRUE)
```

*Documentation reproduced from package tseries, version 0.8-0, License: GPL (see file COPYING), except for ./src/muin2ser.f and ./misc which are free for non-commercial purposes. See file README for details.*