April 2019
Intermediate to advanced
426 pages
11h 13m
English
The process of removing a trend line from a non-stationary data is known as detrending. This involves a transformation step that normalizes large values into smaller ones. Examples could be a logarithmic function, a square root function, or even a cube root. A further step is to subtract the transformation from the moving average.
Let's perform detrending on the same dataset, df_settle, with logarithmic transformation and subtracting from the moving average of two periods, as given in the following Python code:
In [ ]: import numpy as np df_log = np.log(df_settle)In [ ]: df_log_ma= df_log.rolling(2).mean() df_detrend = df_log - df_log_ma df_detrend.dropna(inplace=True) # Mean and standard deviation of detrended data df_detrend_rolling ...
Read now
Unlock full access