About a decade ago, Timon Malloy encountered a problem familiar to families trying to raise two children in New York City: His apartment started to feel too small.

Many New Yorkers, facing such a dilemma, have simply left for cheaper pastures. Mr. Malloy chose a more luxurious route. He bought an apartment below his own, cut a hole in the floor, built a staircase and made his Upper West Side apartment bigger.

“I’m fortunate to be able to afford this,” said Mr. Malloy, 62, who works in commercial real estate. He said he spent millions on renovations, and his new home is “very comfortable.”

The city’s evolution is often measured by watching luxury apartments rise or older buildings crumble. Less apparent are the changes taking place behind the facades and how those changes may be affecting one of the city’s biggest challenges — its housing shortage.

Through apartment combinations like Mr. Malloy’s, and conversions of buildings with several units into single-family homes, the city has lost more than 100,000 apartments since 1950, according to a new analysis of building records shared with The New York Times. Overall, the number of apartments in the city has grown since then, but the pace of new construction has not kept up with the growth in population and demand.

The rate of combinations ramped up in the 1990s as the city came out of an economic crisis. They were clustered in wealthier neighborhoods like the Upper East Side and the West Village in Manhattan or Park Slope in Brooklyn, which housing experts say are the exact neighborhoods, with their easy access to transit and jobs, that should be adding many new homes.

“I’m not trying to begrudge folks who are trying to build a larger apartment as their families grow,” said Adam Brodheim, a preservationist who did the research. “I’m trying to bring attention to the way these actions across the entire city make a meaningful impact on our housing crisis.”

On some streets, many buildings that were built a century or more ago as single-family homes and split during the 1900s into multiple units have once again become single-family homes. In the rowhouses on West 88th Street between Amsterdam Avenue and Columbus Avenue, there are about 173 units. That compares with more than 400 units on the same street in the 1950s and 1960s, according to Mr. Brodheim, who is also a member of Open New York, a nonprofit that advocates for more development.

Sometimes the combinations have been celebrated as an act of restoration.

Take, for example, the Greenwich Village townhouse where the actress Brooke Shields lives, which had been divided into eight apartments before she bought it and restored it to become a single-family house.

In an interview with The New York Times last year, Ms. Shields said that she wanted to give her daughters an experience similar to the one she had growing up on the Upper East Side.

“This had been a dream for me because I wanted my kids to have what I had had with my house on the Upper East Side: to have a feeling of neighborhood, and to have the space which is so hard to come by and so expensive in New York,” Ms. Shields told The Times. “We looked everywhere, but one place was more depressing than the next.”

The house had originally been built as a single-family home.

Ms. Shields could not be reached for comment.

Then there are situations like the one at 12 East 72nd Street, which about 20 years ago had 23 different apartments. In 2002, Steve Croman, a landlord frequently criticized for his aggressive posture toward tenants, bought the six-story building for $5.5 million.

Over the course of four years, Mr. Croman persuaded some tenants to leave, evicted others and turned the entire building into a single-family home for his family.

This took place before Mr. Croman landed in prison in 2017 after he pleaded guilty to grand larceny and other felony charges. He could not be reached for comment.

Toby Thompson was one of the last tenants to leave. He said the apartment he lived in for 13 years — until 2006, when he settled with Mr. Croman — was “every single person’s dream apartment.”

“Half a block from Central Park — that block itself is so historic,” he said. “Some of the fanciest apartment buildings in the city are on that block. I can understand why Croman wanted to move there.”

Mr. Thompson, a creative writing professor who wrote for magazines in New York and worked on books, said he had always wanted to live in New York City. The apartment’s $800 monthly rent made it possible, he said.

After the building was sold, Mr. Thompson moved back to Maryland.

The trend, which has continued since then, is among the reasons some neighborhoods have so little new housing — a troubling outcome when city officials have spoken in dire terms about the need to add housing to improve affordability and fight segregation.

For example, while 3,000 units of new housing were added in the community district that includes the Upper East Side between 2010 and 2021, about 2,000 units were lost through the consolidation of apartments, according to the research. Another 1,000 or so were lost in demolition.

Still, Mr. Brodheim said, he does not oppose consolidations that make staying in the city more appealing for wealthier residents. He pointed out that individual households cannot be blamed for a citywide problem that stems from policy choices local and state politicians made.

“It’s not a problem if you were building a lot of new housing,” he said.

Even as the city grows wealthier, it is not clear that combining apartments will always be a good investment. Bill Caleo, a real estate developer and general partner at the Brooklyn Home Company, which converted an eight-apartment townhouse to a single-family home, said the high cost of renovation only makes sense if you can sell the new home at a high enough price. And he has not seen demand for bigger combined homes increasing over time.

Mr. Malloy said he does not think people should be prevented from joining apartments together. But he acknowledged the need for New York City to create a huge number of new apartments to address the housing crisis.

He now lives alone and works remotely in his apartment, after his children moved out to go to college. .

“For me, it’s good,” he said. “I have a lot of stuff here.”