A level-17 NPC has CR 16. As an example, take a look at this level-17 NPC wizard from d20pfsrd.com.
If you use PC wealth for the NPC, that adds +1 CR:
“For boss NPCs, just give the NPC a PC’s wealth. That increases the boss NPC’s CR by +1, so a zero HD creature with class levels and PC wealth is a CR equal to his class level. We do this pretty much for EVERY major boss of an adventure path.”
I recommend not worrying about the modifiers for boosted stats. Recall that +2 CR should be equivalent to fighting two of the monsters at once; if your boosted stats aren't making the wizard 50% more dangerous, then they're not worth +1 CR. If you really care about the difference, you might consider removing the stats and applying a template instead, as those come with CR adjustments.
CR serves two purposes: (1) it warns you if you're about to give the party a too-easy or too-difficult encounter, and (2) it tells you how much experience to award. Neither of these seem important for your wizard, so arguably you don't need a CR.
On the other hand, you probably want to award experience. The gamemastering section says:
Story Awards: Feel free to award Story Awards when players conclude a major storyline or make an important accomplishment. These awards should be worth double the amount of experience points for a CR equal to the APL. Particularly long or difficult story arcs might award even more, at your discretion as GM.
so that's a good guideline for how much experience to award.
I'll note that many groups would find "a powerful NPC defeated us all and then chose not to kill us" an unsatisfactory ending to an adventure. You might want to try something more conventional, such as allowing the player characters a victory. Of course it's up to you though.