Here is the
IRS explanationAccording to it, you will not be considered a resident if you stay less than 183 days according to the three year calculation.
So using the 120 day example:
2015 - 120 days
2016 - 120 days
2017 - 120 days
2017 = 120 days current + 40 days prior + 20 days 2 years prior for a total of 180 days which is below the 183 day limit.
2018 = 120 days current + 40 days prior + 20 days 2 years prior for a total of 180 days.
Now, if you had stayed 180 days in 2015 and in 2016, then in 2017, you would have 60 days counted for 2016 and 30 days counted for 2015, leaving you a maximum stay of 92 days for 2017.
In addition, you would have to have stayed in the US for a minimum of 31 days in the current year.