Data-driven local polynomial for the trend and its derivatives in economic time series