Analyzes whether consumption data shows systematic trends or unsystematic patterns ("bounces") with respect to price. Includes detection of zero-value reversal/return sequences and allows flexible output based on the level of detail requested. See Rzeszutek et al. (in press) for more details.
check_unsystematic_cp(
data,
delta_threshold = 0.025,
bounce_down_threshold = 0.1,
bounce_up_threshold = 0.1,
bounce_none_threshold = 0.1,
rev_zeroes = 2,
ret_nums = 2,
expected_down = FALSE,
verbose = FALSE,
detailed = FALSE
)A data frame of class cp_unsystematic with core results:
Character: 'down', 'up', or 'none'.
Character: 'up', 'down', 'significant', or 'none'.
Logical. TRUE if any bounce pattern detected.
Integer. Number of upward changes meeting threshold.
Integer. Number of downward changes meeting threshold.
Integer. Detected reversals from 0 to non-0.
Integer. Detected returns from non-0 to 0.
If detailed = TRUE, returns additional columns:
Logical. Significant downward trend.
Logical. Significant upward trend.
Logical. No significant trend.
Logical. Significant bounce up in a downward trend.
Logical. Significant bounce down in an upward trend.
Logical. Significant bounces in no-trend data.
A data frame with columns 'x' and 'y', where 'x' is price and 'y' is consumption.
Numeric. Threshold for detecting log-scale trends (default 0.025).
Numeric. Minimum downward bounce proportion to count as significant in upward trends.
Numeric. Minimum upward bounce proportion to count as significant in downward trends.
Numeric. Minimum bounce proportion to count as significant in no-trend cases.
Integer. Length of zero sequences to detect reversals (default 2).
Integer. Length of non-zero sequences to detect returns (default 2).
Logical. If TRUE, suppress reversal detection.
Logical. If TRUE, print intermediate values (default FALSE).
Logical. If TRUE, return additional columns including all trend/bounce flags.
x_seq <- 10^(seq(-2, 2, length.out = 10))
pattern <- data.frame(x = x_seq, y = c(10, 5, 10, 9, 10, 13, 10, 10, 7, 9))
check_unsystematic_cp(pattern)
Run the code above in your browser using DataLab