The inverse association between magnesium intake and risk of vitamin D deficiency only appeared significant among those older than 50 years or with serum PTH level being in the highest or lowest tertile category. This evidence concerns the gene PTH and vitamin D deficiency.