log_interval_vec: Log-Interval Transformation for Constrained Interval...

Description Usage Arguments Details References See Also Examples

View source: R/vec-log_interval.R

Description

The log_interval_vec() transformation constrains a forecast to an interval specified by an upper_limit and a lower_limit. The transformation provides similar benefits to log() transformation, while ensuring the inverted transformation stays within an upper and lower limit.

Usage

1
2
3
4
5
6
7
8
9
log_interval_vec(
  x,
  limit_lower = "auto",
  limit_upper = "auto",
  offset = 0,
  silent = FALSE
)

log_interval_inv_vec(x, limit_lower, limit_upper, offset = 0)

Arguments

x

A positive numeric vector.

limit_lower

A lower limit. Must be less than the minimum value. If set to "auto", selects zero.

limit_upper

An upper limit. Must be greater than the maximum value. If set to "auto", selects a value that is 10% greater than the maximum value.

offset

An offset to include in the log transformation. Useful when the data contains values less than or equal to zero.

silent

Whether or not to report the parameter selections as a message.

Details

Log Interval Transformation

The Log Interval Transformation constrains values to specified upper and lower limits. The transformation maps limits to a function:

log(((x + offset) - a)/(b - (x + offset)))

where a is the lower limit and b is the upper limit

Inverse Transformation

The inverse transformation:

(b-a)*(exp(x)) / (1 + exp(x)) + a - offset

References

See Also

Other common transformations to reduce variance: log(), log1p() and sqrt()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
library(dplyr)
library(timetk)

values_trans <- log_interval_vec(1:10, limit_lower = 0, limit_upper = 11)
values_trans

values_trans_forecast <- c(values_trans, 3.4, 4.4, 5.4)

values_trans_forecast %>%
    log_interval_inv_vec(limit_lower = 0, limit_upper = 11) %>%
    plot()

timetk documentation built on Jan. 19, 2021, 1:06 a.m.