||A theory of imitation is proposed, string parsing, which separates the copying of behavioural organization by observation from an understanding of the cause of its effectiveness. In string parsing, recurring patterns in the visible stream of behaviour are detected and used to build a statistical sketch of the underlying hierarchical structure. This statistical sketch may in turn aid the subsequent comprehension of cause and effect. Three cases of social learning of relatively complex skills are examined, as potential cases of imitation by string parsing. Understanding the basic requirements for successful string parsing helps to resolve the conflict between mainly negative reports of imitation in experiments and more positive evidence from natural conditions. Since string parsing does not depend on comprehension of the intentions of other agents or the everyday physics of objects, separate tests of these abilities are needed even in animals shown to learn by imitation.