Planet Money did a podcast the other day on exactly how the ratings are created. http://www.npr.org/blogs/money/2011/07/26/138721364/the-tues...
TLDL: There's no algorithm. There's no one ratio you can look at. Analysts travel to the country, assess how likely it is to pay its debt, and report back. A few people listen to the evidence then take a vote on the new rating.