laggedMatrix: Create a matrix with lagged columns

Description Usage Arguments Value Note See Also Examples

View source: R/laggedMatrix.R

Description

Create a matrix with lagged columns.

Usage

1

Arguments

x

a vector

k

number of columns, with lag = 0:(k-1).

Value

a matrix with k + length(x) -1 rows and k columns.

Note

This is a rather special function. Use acf for the standard way to estimate autocorrelations and arima for fitting time-series models.

See Also

acf, arima

Examples

1
2
3
4
5
6
7
8
9
x <- sort(runif(100))
xx <- laggedMatrix(x, 3)
matplot(xx)
cor(na.omit(xx))

cor(x[-1], x[-length(x)])

## but note:
print(acf(x, lag=3))

simecolUtil documentation built on May 2, 2019, 5:57 p.m.