People who are hard-wired to show empathy and kindness do so even in the face of a threatening or untrustworthy world.

© opus / a.collectionRF / Getty Images
What makes people behave kindly? Is it the result of having been nurtured in an environment of love and kindness that makes you more likely to treat others the same way? Or perhaps personal experiences of threat and deprivation make you more attuned to the suffering of others? Or maybe it's just a matter of genes?

As with so many human tendencies, displays of kindness are likely to be influenced by both environment and genes. People who have genes that predispose them to empathy and kindness, for example, are steadfast in their charitable behavior, regardless of their current environment, a new study finds. But people with genes that are linked to a weaker inclination toward altruism tend to reduce their charitable behavior and commitment to civic responsibilities, such as political action or jury duty, when they have heightened feelings of fear or being threatened.

The study included 348 American residents with European ancestry. Researchers gauged participants' overall sense of the world as a socially safe or threatening place, by noting how much they agreed with statements like "Human nature is basically good" or "There is more good in the world than bad."

Researchers also asked about the participants' charitable activities and commitment to civic duties. Charitable behaviors included volunteering, giving blood and participating in community groups. Civic commitment was measured by examining participants' responses to questionnaire items related to serving on a jury or paying taxes, even when those duties seem onerous or seemed unfair.

Participants' DNA was also examined for the presence of three genes that previous research has linked with social behavior and altruism. The first was a gene that influences the brain receptor for oxytocin, a hormone linked with trust and with the forging of intimate human relationships, between family members, lovers or friends.

The gene comes in three variants: A/A, A/G or G/G. The G/G version has previously been linked with greater maternal sensitivity to children, increased empathy, more positive emotion and greater ability to cope with stress. It also carries a reduced risk for social anxiety and autism. The A/A version has the opposite characteristics, with the A/G variant falling in between.

Two genes for another receptor, this one for the hormone vasopressin, which is also involved in social connections, were also studied. The genes AVPR1a RS1 and AVPRa RS3 similarly have three versions each (in this case short/short, short/long and long/long) and the long version of both genes is also linked with greater empathy, less social anxiety and lower autism risk. In male rodents, vasopressin receptor levels can predict which animals will be monogamous and which promiscuous, and other variations in the human AVPR gene have been linked to lowered marital quality and relationship problems in men.

The new research found that people who reported the world as being a more scary and threatening place were less likely to engage in charitable activities.  The study couldn't determine whether it was early childhood experiences or current experiences (the surveys were mainly done in late 2002, which means that the 9/11 attacks were probably still on people's minds) or other factors that contributed to the participants' sense of threat. However, the findings fit well with other research suggesting that the effects of positive social experiences and stress counteract: stress and threat tend to reduce altruism, while altruism and social connection alleviate stress. As the authors write: "It is widely accepted that having a strong social network and high quality close relationships promotes physical and mental well-being." 

What the new study reinforces, however, is that those who are genetically predisposed to be kind may be less socially deterred by threat, but those for whom socializing itself can produce anxiety may tend to become even more withdrawn than to reach out in times of fear.

Nonetheless, understanding that threat can make us less likely to connect - even when connection is the best way to reduce threat - may help everyone make healthier choices.

Maia Szalavitz is a health writer for TIME.com. Find her on Twitter at @maiasz. You can also continue the discussion on TIME Healthland's Facebook page and on Twitter at @TIMEHealthland.