Researchers at the Department of Veterans Affairs and the National Institutes of Health have developed a database they say can identify veterans with a high likelihood of suicide, in much the same way consumer data is used to predict shopping habits.

In a study published Thursday in The American Journal of Public Health, researchers reported that a computer algorithm using hundreds of variables among millions of V.A. patients was able to correctly predict small subgroups with suicide rates up to 80 times higher than V.A. patients as a whole. The study also found that current practices that rely on doctors and other medical staff to flag high-risk patients miss the vast majority of such veterans.

“So much of suicide prevention is throwing things at a wall and hoping they will stick,” said Caitlin Thompson, the V.A.’s deputy director for suicide prevention and an author of the study. “We haven’t been able to target people, so having something like this is such a gift.”

The suicide rate for veterans has been much higher than that of the civilian population for years, and it has risen sharply among young veterans since 2009. The V.A. estimates the suicide rate for male veterans younger than 29 is 80 per 100,000 — about four times the comparable civilian rate. Data shows the rate for female veterans, though much lower than the male rate, is six times the comparable civilian figure. Increased mental health staff and traditional suicide prevention efforts have so far failed to bring the rates down.