trend_adj: Trend adjustment

View source: R/gttrend_adj.R

trend_adjR Documentation

Trend adjustment

Description

trend_adj takes a tibble of time series and returns a tibble with trend adjusted values.

Usage

trend_adj(series, method = "moving_avg", log.trafo = FALSE)

Arguments

series

The input tibble in tidy form with columns time, value and optional column id. Be careful, that when using the method moving_avg, you can only use a series with one keyword respective category.

method

As trend adjustment method, one can choose between "moving_avg", "firstdiff", and "comtrend." See Details for more information.

log.trafo

Logical, indicates if value should be transformed to log(value).

Value

Returns a tibble with trend adjusted values and a date column.

For a trend method, there can be choosen between "firstdiff", "moving_avg" and "comtrend". If you choose "firstdiff", first differences with lag = 1 are computed. If you choose the moving average, the time series will be decomposed into its components and the trend will be subtracted from the whole time series (using loess). With "comtrend", there is a polynom of degree 5 with id-fixed effects estimated, which captures the common trend of a sample of categories in Google Trends. The residuals are then used as the adjusted series. For further detail, see Woloszko et al. (2020) and the function est_trend().


johannes97s/ifwtrends documentation built on Oct. 9, 2022, 7:01 p.m.