# acf.spikeTrain: Auto- Covariance and -Correlation Function Estimation for... In STAR: Spike Train Analysis with R

## Description

The function `acf.spikeTrain` computes (and by default plots) estimates of the autocovariance or autocorrelation function of the inter-spike intervals of a spike train.

## Usage

 ```1 2 3 4 5 6``` ```acf.spikeTrain(spikeTrain, lag.max = NULL, type = c("correlation", "covariance", "partial"), plot = TRUE, na.action = na.fail, demean = TRUE, xlab = "Lag (in isi #)", ylab = "ISI acf", main, ...) ```

## Arguments

 `spikeTrain` a `spikeTrain` object or a vector which can be coerced to such an object. `lag.max` maximum lag at which to calculate the acf. Default is 10*log10(N) where N is the number of ISIs. Will be automatically limited to one less than the number of ISIs in the spike train. `type` character string giving the type of acf to be computed. Allowed values are `"correlation"` (the default), `"covariance"` or `"partial"`. `plot` logical. If `TRUE` (the default) the acf is plotted. `na.action` function to be called to handle missing values. `na.pass` can be used. `demean` logical. Should the covariances be about the sample means? `xlab` x axis label. `ylab` y axis label. `main` title for the plot. `...` further arguments to be passed to `plot.acf`.

## Details

Just a wrapper for `acf` function. The first argument, `spikeTrain`, is processed first to extract the inter-spike intervals. `acf.spikeTrain` is mainly used to plot what Perkel et al (1967) call the serial correlation coefficient (Eq. 8) or serial covariance coefficient (Eq. 7), p 400.

## Value

An object of class `"acf"`, which is a list with the following elements:

 `lag` A three dimensional array containing the lags at which the acf is estimated. `acf` An array with the same dimensions as `lag` containing the estimated acf. `type` The type of correlation (same as the `type` argument). `n.used` The number of observations in the time series. `series` The name of the series `x`. `snames` The series names for a multivariate time series.

The lag `k` value returned by `ccf(x,y)` estimates the correlation between `x[t+k]` and `y[t]`.

The result is returned invisibly if `plot` is `TRUE`.

## Author(s)

Christophe Pouzat [email protected]

## References

Perkel D. H., Gerstein, G. L. and Moore G. P. (1967) Neural Spike Trains and Stochastic Point Processes. I. The Single Spike Train. Biophys. J., 7: 391-418. http://www.pubmedcentral.nih.gov/articlerender.fcgi?tool=pubmed&pubmedid=4292791

`acf`, `varianceTime`, `renewalTestPlot`
 ```1 2 3 4 5``` ```## Simulate a log normal train train1 <- c(cumsum(rlnorm(301,log(0.01),0.25))) train1 <- as.spikeTrain(train1) ## Get its isi acf acf.spikeTrain(train1,lag.max=100) ```