Go to this IRS website for information - https://www.irs.gov/individuals/international-taxpayers/form-6166-certification-of-us-tax-residency