Existing models of market herding suffer from several drawbacks. Measures that assume herd behaviour is constant over time or independent of the economy are not only economically unreasonable, but describe the data poorly. First, if returns are stationary, then a two-regime model is required to describe the data. Second, existing models of time-varying herding cannot be estimated from daily or weekly data, and are unable to accommodate factors that explain changes in this behaviour. To overcome these deficiencies, this paper proposes a Markov switching herding model. By means of time-varying transition probabilities, the model is able to link variations in herding behaviour to proxies for sentiment or the macroeconomic environment. The evidence for the US stock market reveals that during periods of high volatility, investors disproportionately rely on fundamentals rather than on market consensus.