Skip to contents

Methods that power time_decompose()

Usage

decompose_twitter(
  data,
  target,
  frequency = "auto",
  trend = "auto",
  message = TRUE
)

decompose_stl(data, target, frequency = "auto", trend = "auto", message = TRUE)

Arguments

data

A tibble or tbl_time object.

target

A column to apply the function to

frequency

Controls the seasonal adjustment (removal of seasonality). Input can be either "auto", a time-based definition (e.g. "1 week"), or a numeric number of observations per frequency (e.g. 10). Refer to time_frequency().

trend

Controls the trend component For stl, the trend controls the sensitivity of the lowess smoother, which is used to remove the remainder. For twitter, the trend controls the period width of the median, which are used to remove the trend and center the remainder.

message

A boolean. If TRUE, will output information related to tbl_time conversions, frequencies, and trend / median spans (if applicable).

Value

A tbl_time object containing the time series decomposition.

References

See also

Examples


library(dplyr)
#> 
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#> 
#>     filter, lag
#> The following objects are masked from ‘package:base’:
#> 
#>     intersect, setdiff, setequal, union

tidyverse_cran_downloads %>%
    ungroup() %>%
    filter(package == "tidyquant") %>%
    decompose_stl(count)
#> frequency = 7 days
#> trend = 91 days
#> # A time tibble: 425 × 5
#> # Index:         date
#>    date       observed season trend remainder
#>    <date>        <dbl>  <dbl> <dbl>     <dbl>
#>  1 2017-01-01        9 -19.8   27.3     1.46 
#>  2 2017-01-02       55  12.4   27.4    15.2  
#>  3 2017-01-03       48  11.3   27.4     9.28 
#>  4 2017-01-04       25   8.91  27.4   -11.4  
#>  5 2017-01-05       22   9.80  27.5   -15.3  
#>  6 2017-01-06        7  -1.26  27.5   -19.3  
#>  7 2017-01-07        7 -21.3   27.5     0.807
#>  8 2017-01-08       32 -19.8   27.6    24.2  
#>  9 2017-01-09       70  12.4   27.6    30.0  
#> 10 2017-01-10       33  11.3   27.6    -5.95 
#> # ℹ 415 more rows