Returns suitably lagged and iterated differences.

# diff.spam(x, lag = 1, differences = 1, ...)
# S4 method for spam
diff(x, lag = 1, differences = 1, ...)

Arguments

x

a spam matrix containing the values to be differenced.

lag

an integer indicating which lag to use.

differences

an integer indicating the order of the difference.

...

further arguments to be passed to or from methods.

Value

A spam matrix with elements similar to

as.spam(diff(as.matrix(x), ...)).

See also

diff in base, precmat.

Author

Reinhard Furrer

Examples

# incidence matrix for a RW(3) model
D <- diff.spam(diag.spam(10), lag=1, differences=3)
t(D)%*%D
#>  [1]   1  -3   3  -1  -3  10 -12   6  -1   3 -12  19 -15   6  -1  -1   6 -15  20
#> [20] -15   6  -1  -1   6 -15  20 -15   6  -1  -1   6 -15  20 -15   6  -1  -1   6
#> [39] -15  20 -15   6  -1  -1   6 -15  19 -12   3  -1   6 -12  10  -3  -1   3  -3
#> [58]   1
#> Class 'spam' (32-bit)