Goldman Sachs Group Inc., which wagered more than $300 billion last year on things like yen rates and bond spreads, just laid down a bet that guys like Nelson “Johnny” Aguilar can stay out of jail.

Aguilar was at a Dunkin’ Donuts near Boston on a Sunday night in March when a shooting outside left a 21-year-old man with a bullet wound to the gut, police said. They arrested Aguilar, a 19-year-old gang member with a criminal record and a tattoo that says “Life’s a Gamble.”

Such crime-blotter moments are Goldman’s concern thanks to a financial product called a social-impact bond. Goldman is anchoring a $21 million plan to help a Boston-area nonprofit called Roca expand its efforts to steer young men like Aguilar away from dealing drugs, stealing cars or committing assaults and murders.

Under the deal, if men targeted by Roca spend 22 percent fewer days in jails and prisons than their peers, Massachusetts would save enough to repay Goldman’s $9 million loan. An even bigger drop in recidivism would hand Goldman as much as $1 million in profit. If Roca fails and too many men end up behind bars, Goldman will lose almost everything it ventured.

“It’s not that different than if you were looking at any company” to invest in, said Andrea Phillips, vice president of Goldman’s Urban Investment Group, who leads the bank’s social- impact bond transactions. “You’re relying on a management team. You’re relying on their human capital, their folks who work at the plant and deliver and do what they’re supposed to do.”

(Goldman isn't the only company looking at bonds to lower recidivism rates. Merrill Lynch has also been involved in a New York program.)

Bottom Line

Young men like Aguilar are part of the bottom line: Each participant Roca keeps out of jail for a year saves Massachusetts $12,400, the state calculated. If it can close a 300-person facility and keep from expanding jail space, it could save $47,500 per person per year.

The beauty of social-impact bonds, adherents say, is that everyone wins. States and municipalities get prevention programs that they might not otherwise be willing or able to fund. Social-service nonprofits get stable, multiyear capital to bring about large-scale change. Investors get a chance to do, and be seen doing, good.

Taxpayers, meanwhile, aren’t on the hook if the interventions don’t work out. As for the young men, Roca’s programs have succeeded in keeping many from returning to jail.

‘Big Deal’

“Economists talk all the time about a ‘Pareto improvement,’ which means something that leaves no stakeholder worse off and leaves some stakeholders better off,” said former U.S. Treasury Secretary Larry Summers, an investor in one such bond. “This is ground zero of a big deal.”

Goldman’s investment hinges on people such as Roca case worker Sulai Rosa, a 27-year-old former gang member who earns $34,000 a year trying to persuade her charges to go straight.

Rosa got an early start on Monday, March 10, the morning after the Dunkin’ Donuts shooting. Even before learning that 15 of the 22 men on her caseload had links to various sides of the gang-related conflict, she began making a case against retaliation. “Someone could have died,” Rosa told one of her charges that day.

Someone’s definitely going to die, the young man said.

“We’re working on de-escalating,” Rosa said.

Figuring out what to do with Aguilar would be trickier. In the nine months since police arrested him with a Mason jar of marijuana and a digital scale, he had been making progress in Roca’s programs, she said. Yet there he was in a cell, facing three charges, including armed assault with the intent to murder a man now lying in the hospital.

Beginning to piece together Aguilar’s role, Rosa feared the worst. “He’s done,” she said.

Values Investing

Social-impact bonds are a quickly expanding part of the nearly $40 billion umbrella of impact or “double bottom-line” investing, in which people seek to align their portfolios with their values.

The first got off the ground under Sir Ronald Cohen, a founder of private-equity firm Apax Partners LLP. In 2010, Social Finance, a nonprofit he co-founded, used £5 million ($8.5 million) in philanthropic funds to reduce recidivism among former prisoners near London.

Shortly after that, Massachusetts -- still reeling from the recession that ended in June 2009, and cutting spending on homeless shelters and early-childhood education -- called for ideas on harnessing social-impact funds. The state decided to tackle recidivism and chose Roca’s proposal, citing its record and emphasis on data collection and analysis.

Due Diligence

Third Sector Capital Partners, a nonprofit started by George Overholser, a founding manager at Capital One Financial Corp., helped recruit investors. Goldman did months of due diligence -- visiting Roca and studying its staffing ratios and methods, Phillips said -- before signing on.

In January, Massachusetts announced the deal, called the Juvenile Justice Pay for Success Initiative. Goldman’s $9 million loan included funds from individual investors. Five philanthropies matched that with junior loans and grants, along with $3.3 million from Roca in deferred service fees, for which it will be reimbursed if the program succeeds.

Similar bets are mushrooming. The first SIB deal in the U.S., also funded in part by Goldman, since 2012 has been helping New York City prevent incarcerated youth from committing new crimes. (Goldman’s $9.6 million pledge is 75 percent backstopped by Bloomberg Philanthropies, formed by Michael Bloomberg, majority owner of Bloomberg News parent Bloomberg LP.) Bank of America Corp. is working with New York state on an initiative to rehabilitate older offenders. Crime isn’t the only target: A deal in Israel would give job training to ultra- Orthodox Jewish men, while Massachusetts is planning one to attack homelessness.

Growing Market

With more than a dozen states and municipalities assembling deals, including Republican-led Ohio and Democratic-controlled Colorado, the market will grow to $500 million by the end of next year, from roughly $80 million now, according to the Rockefeller Foundation, a New York-based philanthropy. In addition, President Barack Obama requested $300 million in his 2015 budget to enable more SIB arrangements.

Massachusetts’ bond, the biggest of its sort, marks a shift for governments. Instead of using money to manage chronic challenges such as reoffending criminals, it seeks to prevent them with Wall Street-style risk analysis and numerical targets.

Work Crews

The U.S. has 2.2 million people in prisons and jails, the world’s largest population behind bars, according to an April 30 report by the National Research Council, a group of scientists that advises the U.S. government. In Massachusetts, the state deems 4,000 men ages 17 to 24 at high risk of incarceration as they leave the juvenile justice system or probation each year. Many return to prison, staying 2.5 years on average and costing the state $291 million.

That’s the target population of Roca -- Spanish for “rock” -- a 26-year-old nonprofit whose aim is to get such men into the legitimate economy with aggressive outreach, cognitive behavioral therapy, job training and work crews. Successful participants leave the two-year program with a steady job, a plan for long-term self-sufficiency and another two years of less intensive follow-up.

Young men involved in Massachusetts’ probation and juvenile justice systems have a 55 percent likelihood, if left on their own, of being incarcerated within three years. Roca’s model cuts that to 37 percent, according to an analysis by the Social- Impact Bond Technical Assistance Lab, which is part of Harvard’s Kennedy School and which helped Massachusetts formulate the deal.

Before, Roca had 14 youth workers intensively serving some 375 young men at any given time, including Aguilar, the nonprofit says. The funds from Goldman and philanthropies that began flowing this year will boost its capacity to about 550 at a time, over seven years.

Chelsea Gangs

Rosa’s job is to persuade her “young people,” as she calls those assigned to her caseload, to join and remain in Roca’s program. Most want nothing to do with her.

Growing up in Chelsea, across the Mystic River from downtown Boston, Rosa began hanging with the Bloods street gang at 12. By 15, she said, she’d started her own chapter. She stabbed people and got stabbed, did and sold drugs, and stopped counting the number of times she got arrested after it hit double digits.

Then she met Susan Ulrich, a youth worker for Chelsea-based Roca.

“She was a stalker,” Rosa said. “She would park in front of my house for hours.”

Wake-Up Calls

Rosa completed the program five years ago. Now, emulating Ulrich’s approach, Rosa pulls participants out of bed and drives them to work beginning at 7:30 a.m. (“There’s a lot of cursing,” she said.) She takes their calls on nights and weekends and buys them lunch at TGI Friday’s when they don’t feel like talking.

“You have to be tough with them and can’t show weakness -- but try to be understanding, too,” she said. “I can’t push them too much, because then they won’t trust me.”

Beat cops and probation officers, too, trust her with information about people on all sides of gang conflicts. Because of that information’s sensitivity, she has set her phone to delete messages every 24 hours, in case she loses it.

Jonathan Velasquez, Rosa’s boyfriend of nine years and father of her two sons, said the job consumes her.

Rosa, with long, light brown hair and a scar above her lip, doesn’t disagree. “This is my way to give back to this community I once helped destroy,” she said.

Rosa is one of Roca’s top-performing workers, according to its metrics, including how many times she reinforces the organization’s message in talks with the men in her caseload.

Stolen Sneakers

Rosa had those conversations with Aguilar earlier in the weekend of the shooting. Learning that someone had stolen some marijuana, $400 and a pair of Air Jordan sneakers from one of Aguilar’s friends, Rosa had spent much of the weekend calling her young people to emphasize the consequences of retaliation -- death or jail, either option severing the men from their families and their ability to earn a paycheck.

Aguilar had little room for error.

Raised mostly by his mother and grandmother in Revere, next to Chelsea, he was 12 when his parents divorced, he said. An uncle who stood in as a father to him was stabbed to death the same year.

“They took something out of me and they just left a lot of anger inside of me,” Aguilar said. After that, gang members protected him. He looked up to them like big brothers. He dropped out of school and racked up at least a dozen arrests, he said.

Fight on Broadway

He met Rosa 16 months ago. She was driving down Broadway, a popular hangout for Bloods and other gang members in Revere, when she spotted an unfamiliar young man pummeling another. She broke up the fight, she said, and when an officer arrived, she persuaded him to let her take the assailant, Aguilar, to Roca instead of arresting him.

By the weekend of the shooting, Aguilar had started preparing for high-school equivalency testing, served on a Roca work crew and earned certificates in occupational safety and retail management.

‘Walk Away’

Proponents of social-impact bonds stress that they aren’t a panacea. Full-throated criticism is scarce.

One detractor is Mark Rosenman, a 30-year veteran of nonprofits. To him, the deals symbolize government’s failure to attack social ills at their roots. “The popularization of these private finance mechanisms in some program areas might eventually allow government to say, ‘Sorry, we couldn’t raise private capital for it,’ and to walk away,” he said.

Roca’s founder and chief executive officer, Molly Baldwin, counters that the cost of doing nothing is too high to justify turning away funding, no matter its source.

“That’s what Wall Street does: They make money,” she said. “But why are we more uncomfortable with that than watching kids die in the street, or go to prison and come out with worse outcomes?”

“If there was another way, I’d go for it. But there isn’t.”

Under the Goldman deal, an independent evaluator reaches at random into the pool of young men leaving lockups or probation and assigns some names to Roca. Later, to calculate payments, the evaluator will compare that group’s recidivism rate against that of the men who didn’t get services, to gauge whether Roca’s fared better.

First in Line

Regardless of Roca’s performance, Goldman will get 5 percent annual interest on its loans. As senior lender, it’s first in line to earn back its principal, triggered by the 22 percent drop in days that participants are incarcerated as well as their success in getting and keeping jobs. With a 40 percent drop in incarceration, Massachusetts would repay the investors $22 million, the same amount it would save. Above that, the state would begin keeping part of the savings.

Rosa learned about the Dunkin’ Donuts shooting March 10 when a colleague texted her two hours before she was due at work. With one hand on the steering wheel, she barreled down Broadway. Her orange Roca sweatshirt made her stand out like a hunter trying to avoid getting shot near a lake full of waterfowl. She parked her 12-passenger Roca van outside a housing project on Cooledge Street, home to many of her flock.

“You need to stay away from this,” she told one of them, peppering her pleas with Spanish. “What is your safety plan?”

From her charges, her fellow youth workers and cops, Rosa soon learned that the shooting about 10 p.m. involved members of the Hill Park and Cooledge Street hoods -- like gangs, but smaller -- attacking a young man who hung out with Bloods. It was the retaliation she’d feared.

Gun in Waistband

A witness told investigators that Aguilar and four others arrived at Dunkin’ Donuts and took turns punching the victim in the face, according to the police report. One pulled a gun from his waistband and shot the victim. Revere police tracked down Aguilar that night. A judge set bail at $50,000.

Police didn’t find a gun on Aguilar. A different man had pulled the trigger, the witness in the police report said. On April 8, prosecutors dropped charges against Aguilar, citing insufficient evidence.

Massachusetts can’t add him to its savings tally yet. Aguilar is due back in court tomorrow to face a misdemeanor drug charge stemming from the marijuana arrest in June 2013.

‘20 Steps Back’

“Sometimes I take 10 steps forward and I’m doing so well, and then something will happen and I’m taking 20 steps back,” Aguilar said, crediting Roca for trying to keep him on track. “They don’t want to see me end up going to jail for the rest of my life.”

Now that Aguilar has done his stint on a Roca work crew, Rosa is helping him look for a job. Last week, they combed online listings for retail jobs -- preferably outside Revere and with night hours, she said, when he’s most prone to trouble in the neighborhood.

“When I was younger I always thought about being here for the rest of my life,” Aguilar said. “I wouldn’t mind leaving and starting somewhere fresh.”