Bad habits such as thumb-sucking and nail-biting in children could have a positive health effect after all, scientists found.

Researchers from New Zealand's Dunedin School of Medicine and McMaster University's Michael G. DeGroote School of Medicine found that children who are thumb-suckers or nail-biters are less likely to develop allergies.

Moreover, children who have both habits are even less likely to be allergic to dust mites, grass, cats, dogs, horses or airborne fungi, scientists said.

"Our findings are consistent with the hygiene theory that early exposure to dirt or germs reduces the risk of developing allergies," Malcolm Sears, professor at McMaster University, said in a press release.

"While we don't recommend that these habits should be encouraged, there does appear to be a positive side to these habits," Sears added.

In the study, which was published in the journal Pediatrics, the researchers analyzed the data from an ongoing study of over 1,000 children born in New Zealand in 1972 or 1973. The children's parents were surveyed about the kids' thumb-sucking and nail-biting habits four times, when the kids were 5, 7, 9 and 11 years old.

The children were also tested for allergies using a skin-prick test when they were 13 years old and later when they were 32 years old.

The researchers found that 38 percent of children who sucked their thumbs and bit their nails had at least one allergy, while 49 percent of kids who did not have these habits had at least one allergy.

Researchers also found that the link between lower risk of allergies and these childhood habits persisted among the participants when they were 32 years old. The link remained even when the researchers took into consideration other factors that could increase a person's risk of allergies, such as whether their parents had allergies, whether they had pets, whether they were breast-fed as infants or whether their parents smoked.

Moreover, researchers discovered that thumb-sucking and nail-biting kids were less likely to have allergies at 13 years old than kids who only had one of the two habits.

According to Dr. Robert Hancox, associate professor of respiratory epidemiology at the University of Otago, New Zealand, environments that have more germs and dirt may help strengthen the immune system.

"[It seems that] exposure to microbial organisms influences our immune system and makes us less likely to develop allergies," Hancox told Live Science.