acfToDf {virtualPollen} | R Documentation |
Computes temporal autocorrelation in a vector, and returns a dataframe for easy plotting.
Description
It reads a vector representing a time series, applies acf
for a given number of lags
Usage
acfToDf(
x = NULL,
lag.max = 100,
length.out = 10
)
Arguments
x |
numeric vector. Must represent a variable sampled at regular times. |
lag.max |
integer, number of lags over which to compute temporal autocorrelation. |
length.out |
integer, total number of lags to consider for plotting. Should be a subset of |
Details
This function computes temporal autocorrelation of a given vector using acf
, and returns a dataframe ready for easy plotting with plotAcf
.
Value
A dataframe with the columns: #'
-
lag: numeric, lag in the time units of
x
with a maximum determined bylag.max
, and a number of unique values determined bylength.out
-
acf: Pearson correlation index returned by the
acf
for a given number of lags for the given lag. -
ci.max: Maximum value of the confidence interval of
acf
. -
ci.min: Minimum value of the confidence interval of
acf
.
Author(s)
Blas M. Benito <blasbenito@gmail.com>
See Also
Examples
#getting a driver
data(driverA)
#computing temporal autocorrelations
x.df <- acfToDf(
x = driverA,
lag.max = 1000,
length.out = 100
)
str(x.df)
#plotting output
plotAcf(x.df)