  Shannon entropy is the most common metric to measure the degree of randomness
of time series in many fields, ranging from physics and finance to medicine and
biology. Real-world systems may be in general non stationary, with an entropy
value that is not constant in time. The goal of this paper is to propose a
hypothesis testing procedure to test the null hypothesis of constant Shannon
entropy for time series, against the alternative of a significant variation of
the entropy between two subsequent periods. To this end, we find an unbiased
approximation of the variance of the Shannon entropy's estimator, up to the
order O(n^(-4)) with n the sample size. In order to characterize the variance
of the estimator, we first obtain the explicit formulas of the central moments
for both the binomial and the multinomial distributions, which describe the
distribution of the Shannon entropy. Second, we find the optimal length of the
rolling window used for estimating the time-varying Shannon entropy by
optimizing a novel self-consistent criterion based on the counting of
significant variations of entropy within a time window. We corroborate our
findings by using the novel methodology to test for time-varying regimes of
entropy for stock price dynamics, in particular considering the case of meme
stocks in 2020 and 2021. We empirically show the existence of periods of market
inefficiency for meme stocks. In particular, sharp increases of prices and
trading volumes correspond to statistically significant drops of Shannon
entropy.
