Diet and lifestyle factors can affect thyroid function, including stress, exercise, and the consumption of certain foods.