gtseas_adj: Seasonal adjustment of a Google Trends time series

View source: R/gtseas_adj.R

gtseas_adjR Documentation

Seasonal adjustment of a Google Trends time series

Description

This function can either seasonal adjust a given time series or create a new time series based on a Google Trends search query and then directly seasonally adjust it.

Usage

gtseas_adj(
  timeseries = NULL,
  keyword = NA,
  category = NA,
  geo = "DE",
  timeframe = paste("2006-01-01", Sys.Date()),
  method = "arima",
  freq = "monthly",
  log.trafo = FALSE
)

Arguments

timeseries

A already created time series to seasonal adjust. Preferably already as tsibble or tibble. If another data format is given, it will be coerced to a tsibble.

keyword

A vector (chr) of keywords to search for.

category

A vector (numeric) of category numbers to search for.

geo

The region to search in.

timeframe

A time frame to search the queries in consisting of a start date and an end date in YYYY-MM-DD form.

method

Character, which method for adjustment should be choosen. See Details.

freq

Character "month" or "quarter" for the frequency.

log.trafo

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

Value

Returns a tsibble with sesonal adjusted values and a date column. Any key column will be lost. Therefore, you should only to this with single time series with one keyword or category.

Methods

With the seasonal adjustment method, a choice can be made between "firstdiff" and "arima". If "firstdiff", first derivatives with lag = 1 are computed. If "arima", the X-13ARIMA-SEATS procedure is used (performed by seasonal::seas() from the seasonal package).

Examples

series <- trendecon::ts_gtrends(c("ikea", "saturn"), time = "2020-01-01 2021-06-01")
gtseas_adj(series, freq = "month", log.traf = TRUE, method = "firstdiff")

gtseas_adj(category = 179, timeframe = "2015-01-01 2021-01-01", method = "arima")

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