It is common to consider financial markets as made up of stocks which can be grouped according to similar characteristics. The understanding of grouping characteristics is important for understanding the overall dynamics of the market in which such clustering takes place. The appearance of grouping or clustering behaviour may be due mainly to random effects due to overlapping properties when the number of stocks is high. Hence it is necessary to investigate methods for measuring possible noise contributions to clustering and also methods of reducing the noise contributions. Grouping may change over time. It is necessary to identify the time horizons for which clusters are stable. We identify sectors, groups of stocks which display similar behaviour, and states, time periods for which the market sectors behave similarly. We use maximum likelihood methods developed by Marsili (2002) based on the ansatz of Noh (2000). Additionally, we implement both a deterministic recursive merging algorithm as well as a simulated annealing search algorithm. These methods are use a novel non-parametric formulation of a pricing model that can be interpreted in terms of the q-state Potts model.