The variable X-ray spectrum of Markarian 766 - I. Principal components analysis