http://www.irs.gov/taxtopics/tc851.html
The second test is the "substantial presence test." To meet this test, you must have been physically present in the United States on at least 31 days during the current year, and 183 days during the 3 year period that includes the current year and the 2 years immediately before. To satisfy the 183 days requirement, count all of the days you were present in the current year, and one━third of the days you were present in the first year before the current year, and one━sixth of the days you were present in the second
year before the current year. Do not count any day you were present in the United States as an "exempt individual" or commute from Canada or Mexico
to work in the United States on more than 75% of the workdays during your working period. An exempt individual may be anyone in the following categories:
A foreign government━related individual,
A teacher or trainee with a J or Q visa who substantially complies with the requirements of the visa,
A student with an F, J, M, or Q visa who substantially complies with the requirements of the visa; or
A professional athlete temporarily present to compete in a charitable sports event.
http://www.irs.gov/taxtopics/tc354.html
To claim a dependency exemption for a qualifying relative, the following
dependency tests must be met:
The member of household or relationship test,
The citizen or resident test,
The joint return test,
The gross income test, and
The support test.