Yeah I've still got all of the data, but no TV to play it on :(
As far as I know to get star rankings you do the following (I got this from an online forum):
50cc - Make sure you do not hit too many environmental hazards, fall off too often or drive offroad for too long, because all 3 of those directly influence your rank in 50cc! I have had triple star runs with like 3 blue shells a race, 57 points, etc (in 50cc). I compared them to my 60-point, 90% first place triple star runs (in 50cc). They all had the same thing in common: I never fell off or got hit by stuff like chain chomps, crushing ceilings and lava balls.
100cc, 150cc, mirror - Forget about not messing up, as it does not directly influence the ranking like in 50cc. Only two things matter: get 60 points and STAY FIRST. There is a magic percentage for each of the modes, if you do not stay first at least that percentage of the time you will not get a triple star.
Take this as you will, I have played Grand Prix extensively, and from my experience those are the only factors. The reason people think things like falling off in 100cc/150cc/mirror deduct from ranking is because falling off is an indirect influence. What I mean by that is that, while such mistakes do not themselves deduct rank, they can (and usually do) result in the CPU passing you, reducing the % of time you stayed first. I have had plenty of 100cc/150cc/mirror games where I fell off/got hit multiple times at each stage but got the triple star, just because the CPU was still unable to catch up.
I did find one exception to these rules: off-road. I've been experimenting with the Magikruiser in 150cc/mirror Banana Cup and I've noticed that going off-road for too long (without a speed-boosting item) deducts from rank even in mirror. From what I've observed so far, it doesn't deduct much at all and how much it deducts depends on how strong the off-road is (how much it slows you down by). For example, taking the shortcut more than once in Delfino Square without a shroom can deduct a whole star, compared to me having to stay in the blue water in Shy Guy Beach over 50% of the time to produce the same result.
In other words... be perfect 99% of the time and pray you don't get blue shelled.