In the U.S. tax system, foreign nationals are considered either 'non-residents for tax purposes' or 'residents for tax purposes'. Your tax residency status depends on your current immigration status and/or how long you've been in the U.S.
Determining Tax Residency Status
If you are not a U.S. citizen, you are considered a 'non-resident for tax purposes' unless you meet the criteria for one of the following
must be physically present in the United States for 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 that, counting:
All the days you were present in the current year, and
1/3 of the days you were present in the first year before the current year, and
1/6 of the days you were present in the second year before the current year.
If total equals 183 days or more = Resident for Tax
If total equals 182 days or less = Nonresident for Tax
you must know the number of days you were physically present in the U.S. over the last 3-4 years.
EXCEPTIONS
F1/2 students receive 5 “exempt” years. Not exempt from tax, but of counting physical days of presence in the U.S. If you have been in the U.S. for fewer than 5 calendar years (including any previous F-1/2 statuses at any point), then you are considered a 'Non Resident for Tax Purposes.
**“Exempt” years are CALENDAR years, not years from date of arrival (e.g. if you arrived 9/23/2017, 2017 would be counted as one, total calendar year and you would have four calendar years remaining).