log1p() Transform to Linear Scaleexpm1_decomposed.Rdexpm1_decomposed() converts the output of
time_decompose() back to the linear
scale when the input to time_decompose() is on the log scale. This amounts
to selective sequential application of expm1() to
the component columns.
expm1_decomposed(.data)The output of time_decompose()
The input decomposition with expm1() applied appropriately
Because log-scale additive decomposition is multiplicative decomposition on the linear scale, functions which automatically perform decomposition on the log scale yield unexpected output. To remedy this, an approximate conversion back to the linear scale can be performed. The steps are as follows (with all exponentiation follow by an "add-1" operation):
observed: Exponentiate the observed column
trend: Exponentiate the trend column
season: Exponentiate trend + season and subtract the
exponentiated trend
remainder Subtract the exponentiated trend and season
from the exponentiated observed values (observed - trend - season)
The underlying code is perhaps a simpler explanation than the above; consult it for further exposition.
Exponentiating the observed values is a simple inverse transform; however,
the component columns require some assumptions to convert back to a linear
scale. This process uses the trend as a "base" and simply exponentiates it
as in observed. This can then be used to derive the season component, and
the remainder is whatever is left over. While this is not a theoretically
valid process (there is none for this operation), it is consistent with
treating the trend as a smoothed version of observed, which is usually
done in practice. Once this assumption is made, the season transformation
becomes valid. The remainder is then assumed to be the difference between
the observed values (observed) expected values (season + trend), as
usual.
time_decompose(),
expm1(), calling function
prep_linelist()