get_abnorm_hist {globaltrends}R Documentation

Compute abnormal changes in data - historic baseline

Description

The function allows to compute changes in search scores, voi, and doi and shows percentile of changes to identify abnormal changes. In combination with various write functions in R, the functions allow exports from the database to local files.

Usage

get_abnorm_hist(data, ...)

## S3 method for class 'exp_score'
get_abnorm_hist(
  data,
  train_win = 12,
  train_break = 0,
  type = c("obs", "sad", "trd"),
  ...
)

## S3 method for class 'exp_voi'
get_abnorm_hist(
  data,
  train_win = 12,
  train_break = 0,
  type = c("obs", "sad", "trd"),
  ...
)

## S3 method for class 'exp_doi'
get_abnorm_hist(
  data,
  train_win = 12,
  train_break = 0,
  measure = c("gini", "hhi", "entropy"),
  ...
)

Arguments

data

Object of class exp_score, exp_voi or exp_doi generated through export_... functions.

...

Further arguments passed to or from other methods.

train_win

Object of type numeric. Length of rolling average training window in months. Defaults to 12.

train_break

Object of type numeric. Length of break between rolling average training window and date in months. Defaults to 1.

type

Object of type character indicating the type of time series-column from data_score, takes either obs, sad, or trd. Defaults to "obs".

measure

Object of type character indicating the measure used for DOI computation for which abnormal changes should be analyzed. Takes either gini, hhi, or entropy. Defaults to "gini".

Details

The function computes abnormal changes in search scores, VOI, or DOI for each date. We define "abnormal" in terms of deviation from a historic baseline value. To compute the historic baseline value, the function computes a moving average. Users can specify the window for moving average training train_win and a break between training and the given date train_break. Abnormal changes are the difference between the moving average and the respective search score, VOI, or DOI. To highlight abnormal changes, the function computes a historic percentile rank for each abnormal change within the distribution of abnormal changes. Low percentile ranks signify abnormally high negative changes. High percentile ranks signify abnormally high positive changes. The function uses the output from export_... functions as input. As get_abnorm_hist offers no additional filters, users are advised to use filters in the export_... functions or to pre-process data before using get_abnorm_hist.

Value

The functions export and filter the respective database tables and return objects of class ⁠"tbl_df", "tbl", "data.frame"⁠.

See Also

Examples

## Not run: 
data <- export_score(keyword = "amazon")
get_abnorm_hist(data, train_win = 12, train_break = 0, type = "obs")

data <- export_voi(keyword = "amazon")
get_abnorm_hist(data, train_win = 12, train_break = 0, type = "obs")

data <- export_score(keyword = "amazon")
get_abnorm_hist(data, train_win = 12, train_break = 0, measure = "gini")

## End(Not run)


[Package globaltrends version 0.0.14 Index]