Officially, it's CR = level. However, at higher levels NPCs tend to be weaker, mainly because of equipment issues (they get less.)
It also breaks down between spellcasters and fighters - fighters are more dependent on equipment, so an NPC fighter with less equipment is less powerful than a spellcaster with less equipment. The NPC spellcaster also has the advantage of being able to blow away all of his spell slots in the encounter (using the last one or two to escape) which is something a PC spellcaster rarely has the luxury of doing... even if they're actually capable of doing so.