A wrapper for the acf function from the stats package that extracts only the temporal autocorrelation at a lag of one timestep (which is the type of temporal autocorrelation that this package simulates). The function omits NA values in the time series.

autocorrelation(x, biasCorrection = TRUE)

Arguments

x

A numeric vector.

biasCorrection

Autocorrelation estimates are biased for short time series. The function can correct for this bias in the manner proposed by Quenouille (1949). Set to TRUE by default.

Value

A single numeric value: the estimate of the temporal autocorrelation with a lag of 1.

Examples

rednoise <- colored_noise(timesteps = 50, mean = 0.5, sd = 0.2, phi = 0.3) autocorrelation(rednoise)
#> [1] 0.2342616