Pub 519 is used to determine your filing status as resident or nonresident alien. Generally, you're a resident alien of the United States for tax purposes if you:
However, like all things there are exceptions to the rules. The pub starts with a nice chart of easy questions with links to the right answer.