Below is per IRS guidelines for residency test:
You will be considered a United States resident for tax purposes if you meet the substantial presence test for the calendar year. To meet this test, you must be physically present in the United States (U.S.) 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 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.
Days of Presence in the United States
You are treated as present in the U.S. on any day you are physically present in the country, at any time during the day. However, there are exceptions to this rule. Do not count the following as days of presence in the U.S. for the substantial presence test:
Days you commute to work in the U.S. from a residence in Canada or Mexico if you regularly commute from Canada or Mexico.
Days you are in the U.S. for less than 24 hours, when you are in transit between two places outside the United States.
Days you are in the U.S. as a crew member of a foreign vessel.
Days you are unable to leave the U.S. because of a medical condition that develops while you are in the United States.
Days you are an exempt individual (see below).