trend_adj | R Documentation |
trend_adj
takes a tibble
of time series and returns a tibble with trend adjusted values.
trend_adj(series, method = "moving_avg", log.trafo = FALSE)
series |
The input tibble in tidy form
with columns |
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). |
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()
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.