1. Genetics. 2. Age. 3. Stressors. The age of initial graying is largely a matter of genetics. However stressors such as nutritional deficiencies, traumatic head injuries, low vitamin b levels, zinc deficiency, severe illness, surgery and marked emotional stress may impact earlier depigmentation in people who are already predisposed to gray hair. In general – genetics plays the biggest role.
Both. The tendency for hair to turn gray (or fall out, as in male-pattern baldness) is hereditary: some people get gray hair "prematurely", i.e., before most other people; for others it takes decades longer. However, emotional stress or physical illness can make gray hair appear sooner. For example, us presidents often gets a lot of gray during their 4 or 8 years in office (check pics online).
A wish. Gray hair is a natural aging process although quite variable in age of onset. Their is not way to change this for yourself. There are a few accounts of people with some profound experience leading to a rapid change in the hair to gray or white. And of course chemotherapy can change the hair color and texture.