residuals: Obtain the residuals from SSA reconstruction

residualsR Documentation

Obtain the residuals from SSA reconstruction

Description

Obtain the residuals from SSA reconstruction

Usage

## S3 method for class 'ssa'
residuals(object, groups, ..., cache = TRUE)
## S3 method for class 'ssa.reconstruction'
residuals(object, ...)

Arguments

object

input object

groups

list of numeric vectors, indices of elementary components used for reconstruction, the entries of the list can be named.

...

further arguments passed to reconstruct routine

cache

logical, if 'TRUE' then intermediate results will be cached in the SSA object.

Details

This function calculates the residuals either from SSA object corresponding to reconstruction using groups arguments, or just extracts the residuals from reconstruction object.

Value

residuals object

See Also

Rssa for an overview of the package, as well as, reconstruct.

Examples

# Decompose 'co2' series with default parameters
s <- ssa(co2)
# Reconstruct the series, grouping elementary series.
r <- reconstruct(s, groups = list(c(1, 4), c(2,3), c(5, 6)))
print(residuals(r))

# If there are several groups, then the residuals are calculated as
# residuals for the model corresponding to the combined model.
r <- reconstruct(s, groups = list(c(6, 7), c(6,7), c(8, 9)))
r1 <- reconstruct(s, groups = list(6:9))
max(abs(residuals(r) - residuals(r1))) # 0 
max(abs(co2 - (r1$F1 + residuals(r1)))) # 0

Rssa documentation built on Sept. 11, 2024, 7:20 p.m.