Extracts the residuals.

# S3 method for class 'RW'
residuals(object, ...)

Arguments

object

A model for which forecasts are required.

...

Other arguments passed to methods

Value

A vector of fitted residuals.

Examples

as_tsibble(Nile) %>%
  model(NAIVE(value)) %>%
  residuals()
#> # A tsibble: 100 x 3 [1Y]
#> # Key:       .model [1]
#>    .model       index .resid
#>    <chr>        <dbl>  <dbl>
#>  1 NAIVE(value)  1871     NA
#>  2 NAIVE(value)  1872     40
#>  3 NAIVE(value)  1873   -197
#>  4 NAIVE(value)  1874    247
#>  5 NAIVE(value)  1875    -50
#>  6 NAIVE(value)  1876      0
#>  7 NAIVE(value)  1877   -347
#>  8 NAIVE(value)  1878    417
#>  9 NAIVE(value)  1879    140
#> 10 NAIVE(value)  1880   -230
#> # ℹ 90 more rows

library(tsibbledata)
aus_production %>%
  model(snaive = SNAIVE(Beer ~ lag("year"))) %>%
  residuals()
#> # A tsibble: 218 x 3 [1Q]
#> # Key:       .model [1]
#>    .model Quarter .resid
#>    <chr>    <qtr>  <dbl>
#>  1 snaive 1956 Q1     NA
#>  2 snaive 1956 Q2     NA
#>  3 snaive 1956 Q3     NA
#>  4 snaive 1956 Q4     NA
#>  5 snaive 1957 Q1    -22
#>  6 snaive 1957 Q2     15
#>  7 snaive 1957 Q3      9
#>  8 snaive 1957 Q4     12
#>  9 snaive 1958 Q1     10
#> 10 snaive 1958 Q2      5
#> # ℹ 208 more rows