Miscellaneous
Elementwise transforms
- signal.apply(function)
Apply a function to each element of the signal.
- Parameters:
function – The name of the function to apply. A non-exhaustive list of standard function transform is:
log
(logarithm),exp
(exponentiation),sqrt
(square root),abs
(absolute value),tanh
(hyperbolic tangent).
A use case for transforming data is to get better properties when creating a model. In many cases, a model performs better if the data has been transformed with the logarithm before estimating the model. Here is an example on how to transform the signal:
US_CivilianUnemploymentRate_Monthly.apply('log')
It is also possible to do this in a modelling context. Then doing something like this can work:
predict(US_CivilianUnemploymentRate_Monthly.apply('log')).apply('exp')
We apply “exp” in the end to transform the predictions back to the original scale.
Handling missing values in weighted sums
- weighted_sum(signal_1, signal_2, ..., signal_n, weights = [w_1, w_2,...w_3], nan_when_missing, normalize)
This function provides a method for handling weighted sums with possible missing values. When the signals have numerical values for a given time the value of weighted_sum is
w_1*signal_1 + w_2*signal_2 + … + w_n*signal_n.
When some signals are not numbers, the weighted sum is taken over only the signals with numerical values.
- Parameters:
signal_j – For j=1, 2, …, n, the signals which are combined.
weights – When a list of n numerical weights is supplied this is the weights in the sum. When no weights are supplied it is assumed that w_j=1.
nan_when_missing – If one of the signals have a missing value (NaN) the value of the sum is set to missing (NaN) if nan_when_missing=True, otherwise the missing values are skipped in the sum.
normalize – If normalize=True the weights w_j are normalized so that the active weights sum to 1.
Example:
Using last reported EPS as a proxy for missing EPS estimate:
weighted_sum(estimate('eps'), actual('eps',alignment='rd'), weights=[100,1], normalize=True)