I am fairly new to forecasting and I am trying to create a demand forecast for my organization; I am following the methodology outlined here. In step 12 of the process, the author subtracts the trend value from observed value to detrend the data (code shown below):
# Using statmodels: Subtracting the Trend Component.
from statsmodels.tsa.seasonal import seasonal_decompose
df = pd.read_csv('https://raw.githubusercontent.com/selva86/datasets/master/a10.csv', parse_dates=['date'], index_col='date')
result_mul = seasonal_decompose(df['value'], model='multiplicative', extrapolate_trend='freq')
detrended = df.value.values - result_mul.trend
My issue is with the last line. If the decomposition is done multiplicatively, why is the trend value be subtracted. Should it not be divided (instead of subtracted)? If Multiplicative Time Series is given by:
Value = Base Level * Trend * Seasonality * Error, has the author made a mistake or is subtraction the only way to detrend the data?